1.10. Using Dates and Times
Dates and times can be important elements in a Web database application. PHP has the ability to recognize dates and times and handle them differently than plain character strings. Dates and times are stored by the computer in a format called a timestamp. However, this isn't a format in which you would want to see the date. PHP converts dates from your notation into a timestamp that the computer understands and from a timestamp into a format familiar to people. PHP handles dates and times with built-in functions.
NOTE
The timestamp format is a Unix Timestamp, which is an integer that is the number of seconds from January 1, 1970, 00:00:00 GMT (Greenwich Mean Time) to the time represented by the timestamp. This format makes it easy to calculate the time between two dates — just subtract one timestamp from the other.
1.10.1. Setting local time
With the release of PHP 5.1, PHP added a setting for a default local time zone to php.ini. If you don't set a default time zone, PHP will guess, which sometimes results in GMT. In addition, PHP displays a message advising you to set your local time zone.
To set a default time zone, follow these steps:
Open php.ini in a text editor.
Scroll down to the section headed [Date].
Find the setting date.timezone =.
If the line begins with a semicolon (;), remove the semicolon.
Add a time zone code after the equal sign.
You can see a list of time zone codes in Appendix H of the PHP online manual at www.php.net/manual/en/timezones.php ...
Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.