PHP获取用户';s时区
更改服务器后,我收到以下错误PHP获取用户';s时区,php,timezone,Php,Timezone,更改服务器后,我收到以下错误 <b>Warning</b>: date() [<a href='function.date'>function.date</a>]: 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
<b>Warning</b>: date() [<a href='function.date'>function.date</a>]: 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 'America/New_York' for
'EST/-5.0/no DST' instead in <b>/sessions.php</b> on line <b>8001</b>
但我不确定这是怎么回事
那么,如何获取用户的时区,然后将其设置为内置PHP变量,或者将其与
date()
一起使用?如警告所述,您应该:
date.timezone
;或date()之前设置date\u default\u timezone\u set()
在php.ini文件中设置时区,注意:
$date=$date=date()
?重新声明$date
?“如果您在我的任何内容中看到一些不直观/愚蠢的内容,请注意它;它已被其他人编辑过”我认为这里不是这种情况。不确定为什么您的[代码]被不正确地标记为SO。这个错误让人困惑的是什么?您可以使用PHP-GEOIP获取用户的时区。请参考此链接,希望对您有所帮助
$date = date('Y-m-d G:i:s');