Filtering by Time Period5:14 with Alena Holligan
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.
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.
You need to sign up for Treehouse in order to download course files.Sign up