Stalinko
Stalinko

Reputation: 3646

PHP date() returns different timezones for different timestamps

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?

Upvotes: 2

Views: 47

Answers (2)

Blaatpraat
Blaatpraat

Reputation: 2839

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.

Upvotes: 0

Stalinko
Stalinko

Reputation: 3646

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.

Upvotes: 3

Related Questions