PHP Mktime error

Ali picture Ali · Jul 18, 2011 · Viewed 8.3k times · Source

I'm all of a sudden getting the following error on a site that I've done, which has been working fine so far:

A PHP Error was encountered

Severity: Warning

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 'Antarctica/Macquarie' for 'EST/10.0/no DST' instead

This is the code in question:

$stamp=mktime(0,0,0,$month,$day,$year);

What's the issue here? How can I quickly make these errors go away? I'm using mktime in that format in a lot of places and its throwing an error in each place.

Answer

Francois Deschenes picture Francois Deschenes · Jul 18, 2011

As the error says, you either need to specify a timezone using date_default_timezone_set('Antarctica/Macquarie'); or ini_set('date.timezone', 'Antarctica/Macquarie'); in your code or define date.timezone in php.ini.