How to fix warning from date() in PHP" [duplicate]
You need to set the default timezone smth like this :
date_default_timezone_set('Europe/Bucharest');
More info about this in http://php.net/manual/en/function.date-default-timezone-set.php
Or you could use @
in front of date to suppress the warning however as the warning states it's not safe to rely on the servers default timezone
You could also use this:
ini_alter('date.timezone','Asia/Calcutta');
You should call this before calling any date function. It accepts the key as the first parameter to alter PHP settings during runtime and the second parameter is the value.
I had done these things before I figured out this:
- Changed the PHP.timezone to "Asia/Calcutta" - but did not work
- Changed the lat and long parameters in the ini - did not work
- Used
date_default_timezone_set("Asia/Calcutta");
- did not work - Used
ini_alter()
- IT WORKED - Commented
date_default_timezone_set("Asia/Calcutta");
- IT WORKED - Reverted the changes made to the PHP.ini - IT WORKED
For me the init_alter()
method got it all working.
I am running Apache 2 (pre-installed), PHP 5.3 on OSX mountain lion