Y
Y
Yakov Akulov2014-02-21 10:52:28
PHP
Yakov Akulov, 2014-02-21 10:52:28

PHP timezone Etc/GTM: how?

Today I discovered a strange thing. This may be a well-known feature, of course, but
the Japan Timezone is GMT+9
www.timeanddate.com/worldclock/city.html?l=Tokyo
According to the documentation www.php.net/manual/en/timezones.others.php
we can do So

new DateTime('now', new DateTimeZone('Etc/GMT+9'));

To get the current time in Japan, but this code actually gives us GMT-9 time (tried to update timezonedb - same thing).
To get GMT+9 you have to write new DateTimeZone('Etc/GMT-9').
Of course, the documentation says:
Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons.

But it's still pretty weird behavior.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max, 2014-02-21
@AloneCoder

Here's the thing answers.yahoo.com/question/index?qid=2009070714584...

M
Max, 2014-02-21
@AloneCoder

$date = new DateTime('now', new DateTimeZone("Asia/Tokyo"));
echo $date->format('Y-m-d H:i:s');
// 2014-02-21 17:35:52

seems to work correctly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question