Reputation: 53
I'm all of a sudden getting the following error on a site that I've done when I import an excel file to MySQL using the Excel_Reader library.
This is the error message that mktime()
produces:
Message: mktime() [function.mktime]: 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 'Asia/Krasnoyarsk' for '7.0/no DST' instead
The error is because of the following line:
$string = date ($format, mktime($hours, $mins,$secs,
$dateinfo["mon"], $dateinfo["mday"], $dateinfo["year"]));
I'm currently using PHP version 5.3.1. Is this script not compatible with my PHP version? How can I fix this error?
Upvotes: 1
Views: 4398
Reputation: 76656
The error says it all. Relying on system's timezone settings is a bad idea and therefore you 'll need to specify a timezone using one of the following options.
You have three solutions:
Set a default timezone in your PHP script using date_default_timezone_set()
:
date_default_timezone_set("America/Los_Angeles");
Use ini_set()
to set a default timezone:
ini_set('date.timezone', 'America/Los_Angeles');
Define it as date.timezone
in your php.ini
file.
Documentation: date_default_timezone_set()
ini_set()
Hope this helps!
Upvotes: 2