You're not doing anything wrong in your code; it's complaining about the timezone settings in
php.ini
.
In a standard PHP installation, the timezone is set around line 923 of php.ini. In a *nix install, you can find out where your file is located by passing a flag to the command line like so:
~ : php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.5/conf.d/ext-apcu.ini,
/usr/local/etc/php/5.5/conf.d/ext-intl.ini,
/usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.5/conf.d/ext-memcache.ini,
/usr/local/etc/php/5.5/conf.d/ext-xdebug.ini
Look for the date.timezone setting, which is probably commented out or not set. Change it to the value you want to record all your PHP times in. For instance, I'm in Oklahoma, US, so my value is set like this:
date.timezone = America/Chicago
A complete list of timezones is at
http://php.net/manual/en/timezones.php[
^]
Be sure to remove the
;
comment indicator, save the file, and restart the Apache server.