Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP获取用户';s时区_Php_Timezone - Fatal编程技术网

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()
一起使用?

如警告所述,您应该:

  • 在php.ini中设置
    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');