phpwindowstimezoneiana

Convert deprecated timezones php


I'm making the mapping of windows timezones to IANA, use this source https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml

But the problem is that for some of them there only IANA names from deprecated php list https://www.php.net/timezones.others

"Dateline Standard Time" "Etc/GMT+12"

 "Greenland Standard Time" "America/Godthab"

"India Standard Time" "Asia/Calcutta"

 "Nepal Standard Time" "Asia/Katmandu"

What would be the right alternatives for them?


Solution

  • The warnings at the top of the PHP "other time zones" page are reasonable with regard to a user or developer choosing a specific time zone for their application. However, the warnings are lacking context. Specifically:

    With all of this in mind - you can simply use the results of the CLDR Windows zones mapping file directly. You don't need to do any additional translation of links to zones unless you are trying to deliver a canonical result.

    Additionally - you likely don't need to write this code yourself. PHP's Internationalization Package can be installed by adding extension=php_intl.dll to your php.ini file. Then you can use functions like IntlTimeZone::getIDForWindowsID to perform the mapping. It uses the same CLDR file under the hood.