PHP date()为不同的时间戳返回不同的时区
I've faced a very weird behaviour of php date()
function.
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
. Unix timestamps don't content timezone in it that's why date()
must return just currently configured timezone.
PHP version 5.6.23
Any ideas why is that?
我遇到了一个非常奇怪的php 请参阅以下代码: p>
它返回 PHP版本5.6.23 p>
任何想法为什么会这样? p>
div> date() code>函数行为。 p>
date_default_timezone_set('Australia / Melbourne');
echo date('P',1475000000)。 ''。 date('P',1475700000);
code> pre>
+10:00 +11:00 code>
它必须始终 10:00 代码>。 Unix时间戳不包含时区,这就是为什么
date() code>必须只返回当前配置的时区。 p>
http://www.australia.gov.au/about-australia/facts-and-figures/time-zones-and-daylight-saving
Your second timestamp is with DST. The first one is not yet.
I found an answer.
It's because Australia changes time on 2nd October. One timestamp is before it, while another is after, that's why all correct. Thanks all for attention.