|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-03 14:37 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 09:00:01 2025 UTC |
Description: ------------ Result of "date_create" with timezon given: "Mon, 23 May 1955 00:00:00 +0200" After calling "date_timezone_set" for this date the expected result would be the same but instead the result is: "Mon, 23 May 1955 01:00:00 +0200" In case of "Europe/Budapest" timezone 3 dates are affected between 1900.01.01 and 1999.12.31: [0] => Sun, 23 May 1954 00:00:00 +0200 [0] => Mon, 23 May 1955 00:00:00 +0200 [0] => Sun, 03 Jun 1956 00:00:00 +0200 There are timezones where everything works fine, and many ohters that have date inputs that cause this mis-calculation. Thers is no relation between the dates in different timezones but the wrong dates are always the same in a given timezone, so there are no "random" errors. Reproduce code: --------------- $errors = array(); $timezones = array('Europe/Budapest'); // Uncomment the following line to run on all timezones // $timezones = timezone_identifiers_list(); function generate_dates($timezone) { $dates = array(); for($y = 1900; $y <= 1999; $y++) { for($m = 1; $m <= 12; $m++) { for($d = 1; $d <= 31; $d++) { $date = date_create(sprintf('%s-%s-%s 00:00:00', $y, $m, $d), timezone_open($timezone)); if ($date) { $dates[] = $date; } } } } return $dates; } foreach($timezones as $timezone) { $dates = generate_dates($timezone); foreach($dates as $date) { $test = date_format($date, 'r'); date_timezone_set($date, timezone_open($timezone)); if ($test != date_format($date, 'r')) { $errors[$timezone][] = array($test, date_format($date, 'r')); } } print('Timezone: '. $timezone . ', errors: '. count($errors[$timezone]) . "\n"); // Uncomment the following line to display all dates that calculated "wrong" // print_r($errors[$timezone]); // print "\n"; } Expected result: ---------------- Timezone: Europe/Budapest, errors: 0 Actual result: -------------- Timezone: Europe/Budapest, errors: 3