Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
The last filter we're going to create is a filter by date. To keep all the reports in a simple dropdown, we're going to create some predefined ranges: last week, this week, last month, and this month.
Documentation
date() returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().
strtotime() function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC).
Date and Time Usage
Dates and times can start to get interesting when the server that the website is running on is set to a date/time other than your local date/time. When working internationally, it is especially important to consider dates. PHP includes many Date/Time functions and it's a good idea to familiarize yourself with the options. One way to manage dates is to have the server and database store dates in a standard such as UTC and then using local time to display those date.
PHP also offer more features using the Object-Oriented method of the DateTime class.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up