anchorcms / anchor-cms

A lightweight blog CMS for PHP
http://anchorcms.com/
GNU General Public License v3.0
3.32k stars 575 forks source link

Timezone issue #637

Closed apmuthu closed 10 years ago

apmuthu commented 10 years ago

The installer shows Asia/Karachi as GMT+6:00

it should be GMT+5:00

CraigChilds94 commented 10 years ago

We use a built in PHP class and round up, the other time zones appear to be correct is this still an issue for you?

apmuthu commented 10 years ago

When we run the actual timezones() function in the file install/run.php, we get:

            [offset] => 21600
            [label] => GMT+6   Asia/Karachi
            [timezone_id] => Asia/Karachi

The source data from the first line in the said function above using the native PHP class DateTimeZone is

$list = DateTimeZone::listIdentifiers();

and the part contents of $list are:

    [231] => Asia/Kabul
    [232] => Asia/Kamchatka
    [233] => Asia/Karachi <-----------
    [234] => Asia/Kashgar
    [235] => Asia/Kathmandu
    [236] => Asia/Kolkata <-----------
    [237] => Asia/Krasnoyarsk
    [238] => Asia/Kuala_Lumpur
    [239] => Asia/Kuching
    [240] => Asia/Kuwait

where it is clear that Asia/Kolkata (GMT+5:30) is after Asia/Karachi (GMT+5:00) Hence this could have been an error with the timezone() function used during the round up of the offset, but:

$list = DateTimeZone::listIdentifiers();
echo $list[233] . chr(10);
// Asia/Karachi
$now = new DateTime(null, new DateTimeZone($list[233]));
$offset = $now->getOffset();
echo $offset;
// 21600 => 6 hours

clearly indicates that PHP itself is erroneous as far as the tz offsets are concerned here for PHP v5.3.1 (obtained from "echo phpversion();") under windows XAMPP v1.7.3.

Hence nothing needs to be done in anchor_cms about this!

systimotic commented 10 years ago

Since it's an error in PHP and probably already fixed in the latest version, I think this can be closed. You're version of PHP actually is older than the requirements say you need, so you're pretty lucky if everything works