Php DateTimeZone-> getOffset () returns invalid offset for GMT time zones

Hopefully someone will notice what is the cause of the problem I'm experiencing.

For all other time zones, such as Europe / Helsinki, calculating the offset below returns the correct values, but for some reason I get a negative value for time zones of the Etc / GMT + 2 style and vice versa (for example, for Etc / GMT- 2 I get a positive value, 7200).

$dateTimeZone = new DateTimeZone('Etc/GMT+2');
echo $dateTimeZone->getOffset(new DateTime("now", new DateTimezone( 'UTC' )));
Expected: 7200 Result: -7200
+3
source share
2 answers

A time zone Etc/GMT+2is what would otherwise be called "GMT -2" or represented as <date time>-02:00.

This is because POSIX represents these types of time zone offsets:

, , . , [+ | -] hh [: mm [: ss]]. , , . 0 23, 0 59.

TZ Variable.

UTC, , +09 -10 . POSIX TZ . , TZ = "JST-9" TZ = "HST10" , . tz , , TZ = "/" TZ = "Pacific/Honolulu", , . POSIX TZ , "GMT-9", , UTC, "GMT".

- .

+5

http://www.php.net/manual/en/timezones.others.php#64310

(+/-) . ,

"Etc/GMT-10" "(GMT + 10: 00) , , ".

+1

All Articles