我有以下数据库应用程序正在使用的时区列表:
Afghanistan Standard Time
Alaskan Standard Time
Arab Standard Time
Arabian Standard Time
Arabic Standard Time
Argentina Standard Time
Atlantic Standard Time
AUS Central Standard Time
AUS Eastern Standard Time
Azerbaijan Standard Time
Azores Standard Time
Canada Central Standard Time
Cape Verde Standard Time
Caucasus Standard Time
Cen. Australia Standard Time
Central America Standard Time
Central Asia Standard Time
Central Brazilian Standard Time
Central Europe Standard Time
Central European Standard Time
Central Pacific Standard Time
Central Standard Time
Central Standard Time (Mexico)
China Standard Time
Dateline Standard Time
E. Africa Standard Time
E. Australia Standard Time
E. Europe Standard Time
E. South America Standard Time
Eastern Standard Time
Egypt Standard Time
Ekaterinburg Standard Time
Fiji Standard Time
FLE Standard Time
Georgian Standard Time
GMT Standard Time
Greenland Standard Time
Greenwich Standard Time
GTB Standard Time
Hawaiian Standard Time
India Standard Time
Iran Standard Time
Israel Standard Time
Jordan Standard Time
Korea Standard Time
Mauritius Standard Time
Mid-Atlantic Standard Time
Middle East Standard Time
Montevideo Standard Time
Morocco Standard Time
Mountain Standard Time
Mountain Standard Time (Mexico)
Myanmar Standard Time
N. Central Asia Standard Time
Namibia Standard Time
Nepal Standard Time
New Zealand Standard Time
Newfoundland Standard Time
North Asia East Standard Time
North Asia Standard Time
Pacific SA Standard Time
Pacific Standard Time
Pacific Standard Time (Mexico)
Pakistan Standard Time
Romance Standard Time
Russian Standard Time
SA Eastern Standard Time
SA Pacific Standard Time
SA Western Standard Time
Samoa Standard Time
SE Asia Standard Time
Singapore Standard Time
South Africa Standard Time
Sri Lanka Standard Time
Taipei Standard Time
Tasmania Standard Time
Tokyo Standard Time
Tonga Standard Time
US Eastern Standard Time
US Mountain Standard Time
Venezuela Standard Time
Vladivostok Standard Time
W. Australia Standard Time
W. Central Africa Standard Time
W. Europe Standard Time
West Asia Standard Time
West Pacific Standard Time
Yakutsk Standard Time
我无法更改应用程序以使用除此以外的任何内容。我需要能够将这些字符串转换为 PHP 可以通过 date() 函数理解的东西。不幸的是,strtotime() 似乎没有做到这一点。除了编写自定义函数来自己做之外,有什么方法可以做到这一点吗?
是Microsoft Windows时区的ID。 PHP 使用 IANA/Olson 时区。 有关详细信息,请参阅时区标记维基。
您可以在此处找到这些区域的映射,作为 Unicode CLDR 的一部分。
我已经为 .NET 编写了转换函数,你可以在这里找到。 您可能可以使用原始源代码在PHP或您选择的任何语言中编写类似的函数。
我觉得这绝对是疯狂的。我已经选择了Windows区域,并将它们与IANA区域对应起来。这是数组:
$microsoftWindowsTimeZones = [
'Dateline Standard Time' => 'Etc/GMT+12',
'UTC-11' => 'Etc/GMT+11',
'Aleutian Standard Time' => 'America/Adak',
'Hawaiian Standard Time' => 'Etc/GMT+10',
'Marquesas Standard Time' => 'Pacific/Marquesas',
'Alaskan Standard Time' => 'America/Anchorage America/Juneau America/Nome America/Sitka America/Yakutat',
'UTC-09' => 'Etc/GMT+9',
'Pacific Standard Time (Mexico)' => 'America/Tijuana America/Santa_Isabel',
'UTC-08' => 'Etc/GMT+8',
'Pacific Standard Time' => 'PST8PDT',
'US Mountain Standard Time' => 'Etc/GMT+7',
'Mountain Standard Time (Mexico)' => 'America/Chihuahua America/Mazatlan',
'Mountain Standard Time' => 'MST7MDT',
'Central America Standard Time' => 'Etc/GMT+6',
'Central Standard Time' => 'CST6CDT',
'Easter Island Standard Time' => 'Pacific/Easter',
'Central Standard Time (Mexico)' => 'America/Mexico_City America/Bahia_Banderas America/Merida America/Monterrey',
'Canada Central Standard Time' => 'America/Regina America/Swift_Current',
'SA Pacific Standard Time' => 'Etc/GMT+5',
'Eastern Standard Time (Mexico)' => 'America/Cancun',
'Eastern Standard Time' => 'EST5EDT',
'Haiti Standard Time' => 'America/Port-au-Prince',
'Cuba Standard Time' => 'America/Havana',
'US Eastern Standard Time' => 'America/Indianapolis America/Indiana/Marengo America/Indiana/Vevay',
'Paraguay Standard Time' => 'America/Asuncion',
'Atlantic Standard Time' => 'America/Thule',
'Venezuela Standard Time' => 'America/Caracas',
'Central Brazilian Standard Time' => 'America/Cuiaba America/Campo_Grande',
'SA Western Standard Time' => 'Etc/GMT+4',
'Pacific SA Standard Time' => 'America/Santiago',
'Turks And Caicos Standard Time' => 'America/Grand_Turk',
'Newfoundland Standard Time' => 'America/St_Johns',
'Tocantins Standard Time' => 'America/Araguaina',
'E. South America Standard Time' => 'America/Sao_Paulo',
'SA Eastern Standard Time' => 'Etc/GMT+3',
'Argentina Standard Time' => 'America/Buenos_Aires America/Argentina/La_Rioja America/Argentina/Rio_Gallegos America/Argentina/Salta America/Argentina/San_Juan America/Argentina/San_Luis America/Argentina/Tucuman America/Argentina/Ushuaia America/Catamarca America/Cordoba America/Jujuy America/Mendoza',
'Greenland Standard Time' => 'America/Godthab',
'Montevideo Standard Time' => 'America/Montevideo',
'Magallanes Standard Time' => 'America/Punta_Arenas',
'Saint Pierre Standard Time' => 'America/Miquelon',
'Bahia Standard Time' => 'America/Bahia',
'UTC-02' => 'Etc/GMT+2',
'Azores Standard Time' => 'Atlantic/Azores',
'Cape Verde Standard Time' => 'Etc/GMT+1',
'UTC' => 'Etc/GMT Etc/UTC',
'GMT Standard Time' => 'Europe/Lisbon Atlantic/Madeira',
'Greenwich Standard Time' => 'Africa/Lome',
'W. Europe Standard Time' => 'Europe/Vatican',
'Central Europe Standard Time' => 'Europe/Bratislava',
'Romance Standard Time' => 'Europe/Paris',
'Morocco Standard Time' => 'Africa/Casablanca',
'Sao Tome Standard Time' => 'Africa/Sao_Tome',
'Central European Standard Time' => 'Europe/Warsaw',
'W. Central Africa Standard Time' => 'Etc/GMT-1',
'Jordan Standard Time' => 'Asia/Amman',
'GTB Standard Time' => 'Europe/Bucharest',
'Middle East Standard Time' => 'Asia/Beirut',
'Egypt Standard Time' => 'Africa/Cairo',
'E. Europe Standard Time' => 'Europe/Chisinau',
'Syria Standard Time' => 'Asia/Damascus',
'West Bank Standard Time' => 'Asia/Hebron Asia/Gaza',
'South Africa Standard Time' => 'Etc/GMT-2',
'FLE Standard Time' => 'Europe/Kiev Europe/Uzhgorod Europe/Zaporozhye',
'Israel Standard Time' => 'Asia/Jerusalem',
'Kaliningrad Standard Time' => 'Europe/Kaliningrad',
'Sudan Standard Time' => 'Africa/Khartoum',
'Libya Standard Time' => 'Africa/Tripoli',
'Namibia Standard Time' => 'Africa/Windhoek',
'Arabic Standard Time' => 'Asia/Baghdad',
'Turkey Standard Time' => 'Europe/Istanbul',
'Arab Standard Time' => 'Asia/Aden',
'Belarus Standard Time' => 'Europe/Minsk',
'Russian Standard Time' => 'Europe/Simferopol',
'E. Africa Standard Time' => 'Etc/GMT-3',
'Iran Standard Time' => 'Asia/Tehran',
'Arabian Standard Time' => 'Etc/GMT-4',
'Astrakhan Standard Time' => 'Europe/Astrakhan Europe/Ulyanovsk',
'Azerbaijan Standard Time' => 'Asia/Baku',
'Russia Time Zone 3' => 'Europe/Samara',
'Mauritius Standard Time' => 'Indian/Mahe',
'Saratov Standard Time' => 'Europe/Saratov',
'Georgian Standard Time' => 'Asia/Tbilisi',
'Caucasus Standard Time' => 'Asia/Yerevan',
'Afghanistan Standard Time' => 'Asia/Kabul',
'West Asia Standard Time' => 'Etc/GMT-5',
'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg',
'Pakistan Standard Time' => 'Asia/Karachi',
'India Standard Time' => 'Asia/Calcutta',
'Sri Lanka Standard Time' => 'Asia/Colombo',
'Nepal Standard Time' => 'Asia/Katmandu',
'Central Asia Standard Time' => 'Etc/GMT-6',
'Bangladesh Standard Time' => 'Asia/Thimphu',
'Omsk Standard Time' => 'Asia/Omsk',
'Myanmar Standard Time' => 'Asia/Rangoon',
'SE Asia Standard Time' => 'Etc/GMT-7',
'Altai Standard Time' => 'Asia/Barnaul',
'W. Mongolia Standard Time' => 'Asia/Hovd',
'North Asia Standard Time' => 'Asia/Krasnoyarsk Asia/Novokuznetsk',
'N. Central Asia Standard Time' => 'Asia/Novosibirsk',
'Tomsk Standard Time' => 'Asia/Tomsk',
'China Standard Time' => 'Asia/Macau',
'North Asia East Standard Time' => 'Asia/Irkutsk',
'Singapore Standard Time' => 'Etc/GMT-8',
'W. Australia Standard Time' => 'Australia/Perth',
'Taipei Standard Time' => 'Asia/Taipei',
'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar Asia/Choibalsan',
'Aus Central W. Standard Time' => 'Australia/Eucla',
'Transbaikal Standard Time' => 'Asia/Chita',
'Tokyo Standard Time' => 'Etc/GMT-9',
'North Korea Standard Time' => 'Asia/Pyongyang',
'Korea Standard Time' => 'Asia/Seoul',
'Yakutsk Standard Time' => 'Asia/Yakutsk Asia/Khandyga',
'Cen. Australia Standard Time' => 'Australia/Adelaide Australia/Broken_Hill',
'AUS Central Standard Time' => 'Australia/Darwin',
'E. Australia Standard Time' => 'Australia/Brisbane Australia/Lindeman',
'AUS Eastern Standard Time' => 'Australia/Sydney Australia/Melbourne',
'West Pacific Standard Time' => 'Etc/GMT-10',
'Tasmania Standard Time' => 'Australia/Hobart Australia/Currie',
'Vladivostok Standard Time' => 'Asia/Vladivostok Asia/Ust-Nera',
'Lord Howe Standard Time' => 'Australia/Lord_Howe',
'Bougainville Standard Time' => 'Pacific/Bougainville',
'Russia Time Zone 10' => 'Asia/Srednekolymsk',
'Magadan Standard Time' => 'Asia/Magadan',
'Norfolk Standard Time' => 'Pacific/Norfolk',
'Sakhalin Standard Time' => 'Asia/Sakhalin',
'Central Pacific Standard Time' => 'Etc/GMT-11',
'Russia Time Zone 11' => 'Asia/Kamchatka Asia/Anadyr',
'New Zealand Standard Time' => 'Pacific/Auckland',
'UTC+12' => 'Etc/GMT-12',
'Fiji Standard Time' => 'Pacific/Fiji',
'Chatham Islands Standard Time' => 'Pacific/Chatham',
'UTC+13' => 'Etc/GMT-13',
'Tonga Standard Time' => 'Pacific/Tongatapu',
'Samoa Standard Time' => 'Pacific/Apia',
'Line Islands Standard Time' => 'Etc/GMT-14'
];
你可以像这样使用它:
$windowsTimeZone = 'Pacific Standard Time';
$ianaTimeZone = $microsoftWindowsTimeZones[$windowsTimeZone];
由于时区可能会更改或不时添加新时区,因此最好开发一个解决方案以从源中获取最新信息,然后对其进行解析。