Reputation: 399
I want to convert a date - 2012-05-25 to the unix timestamp. When i'm using the strtotime() function, it says
PHP Warning: strtotime(): 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/Calcutta' for 'IST/5.0/no DST' instead in /var/www/html/__modules/tickets/library/Notification/RD_time.php on line 323.
Please help me out. I need to flush these reports by tonight.
Upvotes: 1
Views: 7566
Reputation: 41
You can add the following at the beginning of your code:
date_default_timezone_set('Africa/Lagos');//or change to whatever timezone you want
If you want to make this one time, you can put the timezone in your php.ini file. You can search for date.timezone
, You should have a block like this in your php.ini file:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Africa/Lagos
Be sure to restart the server (service httpd restart
on linux).
The list of timezones can be found here http://www.php.net/manual/en/timezones.php.
Upvotes: 1
Reputation: 146310
Just do what it says in the warning and use date_default_timezone_set
For example:
date_default_timezone_set('America/New_York');
Upvotes: 9