简体   繁体   English

PHP date()针对不同的时间戳返回不同的时区

[英]PHP date() returns different timezones for different timestamps

I've faced a very weird behaviour of php date() function. 我已经遇到了一个很奇怪的php date()函数行为。

See this code: 参见以下代码:

date_default_timezone_set('Australia/Melbourne');
echo date('P', 1475000000) . ' ' . date('P', 1475700000);

It returns +10:00 +11:00 While it must be always +10:00 . 它返回+10:00 +11:00但必须始终为+10:00 Unix timestamps don't content timezone in it that's why date() must return just currently configured timezone. Unix时间戳不包含时区,因此date()必须返回当前配置的时区。

PHP version 5.6.23 PHP版本5.6.23

Any ideas why is that? 有什么想法吗?

I found an answer. 我找到了答案。

It's because Australia changes time on 2nd October. 这是因为澳大利亚在10月2日更改时间。 One timestamp is before it, while another is after, that's why all correct. 一个时间戳记在它之前,而另一个时间戳记在它之后,这就是所有正确的原因。 Thanks all for attention. 谢谢大家的关注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM