Skip to content

Commit

Permalink
Fix tz array
Browse files Browse the repository at this point in the history
The list of time zones included in the 'get_tz_array()' function no longer matches the list of zones supported by PHP!
See the pages "https://www.php.net/manual/fr/timezones.php"

When using these values, this caused a 500 error: "PHP Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (Pacific/Enderbury) " for example =>
$arraytz = get_tz_array();
foreach ($arraytz as $key => $value) {
$date = new DateTime();
$date->setTimezone(new DateTimeZone($value));
}

When several zone names could be used for the same time zone, I favored the canonical name (The primary, preferred zone name).
See the table "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
  • Loading branch information
SylvainLegrand committed Oct 3, 2024
1 parent 97eacef commit a507fdf
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions htdocs/core/lib/date.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,32 @@
function get_tz_array()
{
$tzarray = array(
-11=>"Pacific/Midway",
-10=>"Pacific/Fakaofo",
-9=>"America/Anchorage",
-8=>"America/Los_Angeles",
-7=>"America/Dawson_Creek",
-6=>"America/Chicago",
-5=>"America/Bogota",
-4=>"America/Anguilla",
-3=>"America/Araguaina",
-2=>"America/Noronha",
-1=>"Atlantic/Azores",
0=>"Africa/Abidjan",
1=>"Europe/Paris",
2=>"Europe/Helsinki",
3=>"Europe/Moscow",
4=>"Asia/Dubai",
5=>"Asia/Karachi",
6=>"Indian/Chagos",
7=>"Asia/Jakarta",
8=>"Asia/Hong_Kong",
9=>"Asia/Tokyo",
10=>"Australia/Sydney",
11=>"Pacific/Noumea",
12=>"Pacific/Auckland",
13=>"Pacific/Enderbury"
-11 => "Pacific/Pago_Pago",
-10 => "Pacific/Honolulu",
-9 => "America/Anchorage",
-8 => "America/Los_Angeles",
-7 => "America/Dawson_Creek",
-6 => "America/Chicago",
-5 => "America/Bogota",
-4 => "America/Asuncion",
-3 => "America/Araguaina",
-2 => "America/Noronha",
-1 => "Atlantic/Azores",
0 => "Europe/London",
1 => "Europe/Paris",
2 => "Europe/Helsinki",
3 => "Europe/Moscow",
4 => "Asia/Dubai",
5 => "Asia/Karachi",
6 => "Indian/Chagos",
7 => "Asia/Jakarta",
8 => "Asia/Hong_Kong",
9 => "Asia/Tokyo",
10 => "Australia/Sydney",
11 => "Pacific/Noumea",
12 => "Pacific/Auckland",
13 => "Pacific/Fakaofo",
14 => "Pacific/Kiritimati"
);
return $tzarray;
}
Expand Down

0 comments on commit a507fdf

Please sign in to comment.