如何解决这个strftime()错误

时间:2014-12-12 03:03:40

标签: php

我昨天没有收到错误,但现在我不确定发生了什么

Warning: strftime() [function.strftime]: 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.

我正在使用的代码是:

$date = (isset($_GET['country']) && ($_GET['country'] == 'KE' || $_GET['country'] == 'PH' || $_GET['country'] == 'US')) ? strftime("%m/%d/%Y") : strftime("%d/%m/%Y");
setlocale(LC_TIME, "en_US");

我正在尝试显示访问者所在国家/地区的日期

1 个答案:

答案 0 :(得分:1)

明确声明时区。

的httpd.conf / htaccess的:

SetEnv TZ Country/City

的php.ini

date.timezone = Country/City