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?
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:
All of the time zones listed on that page are still valid IANA time zone identifiers. They work now, and they will continue to work in the future.
Most of them are
Link
entries in the IANA database, which point at the current canonicalZone
entry. For example,Asia/Calcutta
is a link pointing atAsia/Kolkata
. Either are valid and can be used in PHP and other systems.With only a couple of rare exceptions, IANA zone names are never actually "deprecated", they are simply relegated to links and become non-canonical. I should have chosen better wording when I added that column to the Wikipedia table. (Yes, that was me. Perhaps I may update it.)
One rare exception is
Canada/East-Saskatchewan
, removed completely in IANA 2017c due to its long string length and rare usage. If you have this in your database, replace it withAmerica/Regina
.The other rare exception is
US/Pacific-New
, removed completely in IANA 2020b because it created a lot of confusion. It was never a real time zone, but only a link. If you have this in your database, replace it withAmerica/Los_Angeles
.The
Etc/UTC
is the canonical UTC zone. It should continue to be used when setting the default time zone on servers in most cases. It is not deprecated in any way.The zones starting with
Etc/GMT+
orEtc/GMT-
are fixed-offset canonical zones for ships at sea in non-territorial waters. They are also sometimes used for other edge cases. They are not deprecated in any way. Their offsets are intentionally inverted (Etc/GMT+12
= UTC-12).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 yourphp.ini
file. Then you can use functions likeIntlTimeZone::getIDForWindowsID
to perform the mapping. It uses the same CLDR file under the hood.