How to Set Local Time with PHP
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.
Use a text editor such as Notepad, Vi, or TextEdit to open the file. The php.ini file is found in your installation directory for PHP, which is typically located beneath the /etc/ directory on Linux, in the Program Files directory on Windows, and /private/etc/ on Mac.
Scroll down to the section headed [Date].
Find the setting date.timezone =.
If the line begins with a semicolon (;), remove the semicolon.
The semicolon indicates a comment, or a line that's ignored in the file. Removing the semicolon means that PHP will parse the line.
Add a time zone code after the equal sign.
Add a time zone, without quotes, to the line in order to define the time zone that the server resides within. See http://php.net/manual/en/timezones.php for a list of supported time zones and note that you don't need to use quotation marks around the time zone when you define it in the php.ini.
Restart the web server.
PHP programs won't use the new time zone until the web server is restarted. How you accomplish this task depends on your operating system. On Windows there is typically a widget to restart the server in the taskbar. One of the following commands typically works on Linux, depending on the variant and version of Linux:
Debian/Ubuntu: sudo /etc/init.d/apache2 restart
Red Hat/CentOS: service httpd restart
On Mac: sudo /usr/sbin/apachectl restart