Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Why won't timezone_name_from_abbr works with a GMT offset of 8?

Tags:

php

I'm trying to use timezone_name_from_abbr() with an offset of GMT+0800, but it doesn't return the expected timezone:

echo "timezone =" . timezone_name_from_abbr('', 8 * 60 * 60, 0) . '<br/>';

According to the documentation this is supposed to work:

If abbr doesn't exist then the time zone is searched solely by the gmtOffset and isdst.

What I am doing wrong? GMT+0800 is a valid timezone for Asia/Singapore.

like image 858
Extrakun Avatar asked Jul 22 '13 13:07

Extrakun


1 Answers

Not a very fancy answer, but it's a bug (Bug #44780 - some time zone offsets not recognized by timezone_name_from_abbr) that has been around for quite a while.

Basically, this particular timezone (and some others) only resolve to a name when you pass an abbreviation, regardless of what the documentation says.

Btw, the return value is false in the case whereby the function can't resolve the name.

like image 180
3 revs, 2 users 95% Avatar answered Sep 30 '22 19:09

3 revs, 2 users 95%