PHP AdvancedLesson 30Free preview
PHP Date and Time
This lesson is part of PHP · All levels
Summary
PHP has an inbuilt function for handling dates and times, with the main function being date(). This lesson describes the letter formats such as Y, m, d, H, i, and s that determine the output form. You also learn about timestamps and how to convert date text into timestamps with strtotime().
Key points
- Date() format the current time according to the given format character
- Returns the timestamp, which is seconds since January 1, 1970
- Format Y for year, m for month, d for date, H for 24 hours
- Strtotime() change the date text to a timestamp
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.