1

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.

4

2 回答 2

9

只需按照警告中的说明进行操作并使用date_default_timezone_set

例如:

date_default_timezone_set('America/New_York');
于 2012-07-12T13:18:14.537 回答
1

您可以在代码开头添加以下内容:

date_default_timezone_set('Africa/Lagos');//or change to whatever timezone you want

如果你想这样做一次,你可以把时区放在你的 php.ini 文件中。您可以搜索date.timezone,您的 php.ini 文件中应该有这样的块:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Africa/Lagos

请务必重新启动服务器(service httpd restart在 linux 上)。

时区列表可以在这里找到http://www.php.net/manual/en/timezones.php

于 2017-09-28T11:08:50.900 回答