- Details
- Written by Tech Notes
- Published: 13 April 2014
Solution to ZenCart PHP Warning message in Logs folder about function.date usage
Please note that I do not get paid to write these articles.
Symptom: Daily growing disk usage for no seemingly good reason.
Evidence: Use FTP or File Manager tool of WHW1 to check your ZenCart folder of Logs. If you are seeing something LIKE the following message in files within the Logs folder:
[13-Apr-2014 17:32:42 America/Chicago] PHP Warning: date() [<a href='function.date'>function.date</a>]: 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 'America/Chicago' for 'CDT/-5.0/DST' instead in /Your-File-Path/public_html/includes/languages/english.php on line 16
or
[13-Apr-2014 17:32:42 America/Chicago] PHP Warning: date() [<a href='function.date'>function.date</a>]: 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 'America/Chicago' for 'CDT/-5.0/DST' instead in /Your-File-Path/public_html/includes/languages/english/email_extras.php on line 30
or
[13-Apr-2014 17:32:42 America/Chicago] PHP Warning: date() [<a href='function.date'>function.date</a>]: 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 'America/Chicago' for 'CDT/-5.0/DST' instead in /Your-File-Path/public_html/includes/init_includes/init_special_funcs.php on line 36
or
[13-Apr-2014 17:32:42 America/Chicago] PHP Warning: date() [<a href='function.date'>function.date</a>]: 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 'America/Chicago' for 'CDT/-5.0/DST' instead in /Your-File-Path/public_html/includes/counter.php on line 21
or
[13-Apr-2014 17:32:42 America/Chicago] PHP Warning: mktime() [<a href='function.mktime'>function.mktime</a>]: 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 'America/Chicago' for 'CDT/-5.0/DST' instead in /Your-File-Path/public_html/includes/counter.php on line 53
Then the below Solution may resolve your problem.
Solution:
Create a file called datetime_patch_for_v151_or_older.php and put two copies in the two extra_configures folders as so: /Your-Folder-Path/includes/extra_configures/datetime_patch_for_v151_or_older.php and /Your-Folder-Path/Your-Admin-Folder/includes/extra_configures/datetime_patch_for_v151_or_older.php. Inside the datetime_patch_for_v151_or_older.php file put the following code:
/*
* Get time zone info from PHP config
*/
if (version_compare(PHP_VERSION, 5.3, '>='))
{
@date_default_timezone_set(date_default_timezone_get());
}
Alternative Solution:
If the above does not work, then you can try indicating the time zone directly. For example, if your timezone was American/Chicago, then you would change @date_default_timezone_set(date_default_timezone_get()); to @date_default_timezone_set('American/Chicago');