php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70502 Kathmandu time zone offset is wrong
Submitted: 2015-09-15 11:58 UTC Modified: 2015-09-15 14:29 UTC
From: phil dot davis at inf dot org Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.5.29 OS: Multiple
Private report: No CVE-ID: None
 [2015-09-15 11:58 UTC] phil dot davis at inf dot org
Description:
------------
NPT is supposed to be the abbreviation for Nepal Time (Asia/Kathmandu) 
http://www.timeanddate.com/time/zones/

but timezone_name_from_abbr("NPT") returns:

string(16) "America/St_Johns"

DateTimeZone::listAbbreviations() shows Asia/Kathmandu with offset 19800.

19800 = 3600 * 5.5 which is UTC+05:30 - that is the time zone for Indian cities like Kokata.

Nepal Kathmandu is UTC+05:45 so the offset should be 3600 * 5.75 = 20700



Test script:
---------------
$x = timezone_name_from_abbr("NPT");
var_dump($x);

$y = DateTimeZone::listAbbreviations();
var_dump($y);


Expected result:
----------------
$x should have "Asia/Kathmandu"

The output in $y should have for Asia/Kathmandu and Asia/Katmandu

    [7]=>
    array(3) {
      ["dst"]=>
      bool(false)
      ["offset"]=>
      int(20700)
      ["timezone_id"]=>
      string(14) "Asia/Kathmandu"
    }
    [8]=>
    array(3) {
      ["dst"]=>
      bool(false)
      ["offset"]=>
      int(20700)
      ["timezone_id"]=>
      string(13) "Asia/Katmandu"
    }


Actual result:
--------------
string(16) "America/St_Johns"

In the $y output:

    [7]=>
    array(3) {
      ["dst"]=>
      bool(false)
      ["offset"]=>
      int(19800)
      ["timezone_id"]=>
      string(14) "Asia/Kathmandu"
    }
    [8]=>
    array(3) {
      ["dst"]=>
      bool(false)
      ["offset"]=>
      int(19800)
      ["timezone_id"]=>
      string(13) "Asia/Katmandu"
    }


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-15 12:39 UTC] phil dot davis at inf dot org
Looking in https://github.com/php/php-src/blob/master/ext/date/lib/timezonemap.h
Search for "npt".
Unfortunately lots of places seem to like to use the time zone abbreviation "npt". The first of these is "America/St_Johns". That is a bit unfortunate, but part of life, I guess :)

So the only real problem I see here is with Asia/Kathmandu and Asia/Katmandu being listed in the Indian Stndard Time zone "ist".

The proposed fix for that is the referenced pull request 1522 mentioned here.
 [2015-09-15 14:29 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2015-09-15 14:29 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

As you have already realized, NPT is used for other areas besides Katmandu as well. The original (PHP 4 and PHP 5.0) code had IIRC a link between NPT and the timezone name, so that is why St. Johns is at the top of the list for the NPT code.

But the region did use IST between 1919 and 1985 as I've commented on the Pull Request. There is nothing wrong there.

timezone_name_from_abbr() can make use of a little more information, for example the UTC offset. If you use that with Kathmandu's offset, it works:

var_dump(timezone_name_from_abbr("NPT", 20700));

shows:

string(13) "Asia/Katmandu"
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 01:00:01 2026 UTC