[英]date_default_timezone_get() returns different value than the default timezone set in php.ini
I have set the default timezone in php.ini as date.timezone = "America/Bogota"
, and phpinfo()
returns this value. 我在php.ini中将默认时区设置为
date.timezone = "America/Bogota"
,并且phpinfo()
返回此值。 But on runtime, date_default_timezone_get()
returns America/New_York
, which is not the value I have set. 但是在运行时,
date_default_timezone_get()
返回America/New_York
,这不是我设置的值。 Also, ini_get('date.timezone')
returns an empty value. 同样,
ini_get('date.timezone')
返回一个空值。 I'm using PHP Version 5.6.30-0+deb8u1 with Apache 2.4.10. 我在Apache 2.4.10中使用PHP版本5.6.30-0 + deb8u1。
This has already been asked here , but haven't been answered in 5 years. 这个问题已经在这里提出,但是5年没有得到答复。
I think if by defining on php.ini doesn't work for you, then you can handle it on your php code side during runtime by using something like this 我认为,如果通过在php.ini上定义不适合您,那么您可以在运行时使用类似这样的方法在php代码端进行处理
$date->setTimezone(new DateTimeZone('America/Bogota'));
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.