Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I was coding my CMS for the updater well I am finished with the cod but I get the following error
Warning: date(): 

It is not safe to rely on the system's timezone settings. 
You are *required* to use the date.timezone setting or the date_default_timezone_set() function. 

In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.

We selected 'UTC' for 'UTC/0.0/no DST' instead in /var/www/html/1016/e62ba3298cdecce2b983d4b8c9eecbce/cms upch/update/update.php on line 105


Well here is my code on line 105 in updater.php:
PHP
$message = date('<Y-m-d H:i:s>').$message."\n";


And here is the code for the rest of line 105 in updater.php:
PHP
public function log($message) {
    if ($this->_log) {
        $this->_lastError = $message;

        $log = fopen($this->logFile, 'a');

        if ($log) {
            $message = date('<Y-m-d H:i:s>').$message."\n";
            fputs($log, $message);
            fclose($log);
        }
        else {
            die('Could not write log file!');
        }
    }
}


SO my question is what am I doing wrong?!?!?
Posted

1 solution

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.
 
Share this answer
 
Comments
Braydon 11-Nov-13 17:29pm    
But where would i put the flag into?
Morgan Estes 11-Nov-13 17:33pm    
In the command line (Terminal, or other shell) if you're on Linux or OS X.

If you're on Windows, the command prompt is the same thing, but you may need to specify the location of the php executable.
Morgan Estes 11-Nov-13 17:38pm    
Also, you can create a page on your server with the function call phpinfo(). When you visit that page (I call mine phpinfo.php) it'll give you the location of the .ini files being loaded.
Braydon 11-Nov-13 17:42pm    
Ok thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900