Ali
Ali

Reputation: 267317

PHP Mktime error

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.

Upvotes: 3

Views: 8446

Answers (2)

Francois Deschenes
Francois Deschenes

Reputation: 24989

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.

Upvotes: 7

SeanCannon
SeanCannon

Reputation: 78046

Can you confirm that $month, $day, and $year are INT - or even not NULL?

Also look into date_default_timezone_set()

Upvotes: 0

Related Questions