Bug #69186 [NEW]: Unexpected behavior using 'back of' or 'front of' with timezone specification

From: Date: Wed, 04 Mar 2015 16:35:53 +0000
Subject: Bug #69186 [NEW]: Unexpected behavior using 'back of' or 'front of' with timezone specification
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191148@lists.php.net to get a copy of this message
From: ryosuke_i_628 at yahoo dot co dot jp Operating system: Windows 7 PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:Unexpected behavior using 'back of' or 'front of' with timezone specification Description: ------------ The following formats cause strange time difference of 12 hours. - 'back of 1 Asia/Tokyo' - 'first of 1 Asia/Tokyo' The test script was executed on 2015-03-05 01:34:00 +0900. Test script: --------------- <?php // Set PHP default timezone into UTC. date_default_timezone_set('UTC'); // Checked items. $list = [ 'now' => [ 'now' => null, 'now Asia/Tokyo' => null, 'Asia/Tokyo now' => null, 'now +0900' => null, '+0900 now' => null, ], 'next hour' => [ 'next hour' => null, 'next hour Asia/Tokyo' => null, 'Asia/Tokyo next hour' => null, 'next hour +0900' => null, '+0900 next hour' => null, ], 'front of 1' => [ 'front of 1' => null, 'front of 1 Asia/Tokyo' => null, 'Asia/Tokyo front of 1' => null, 'front of 1 +0900' => null, '+0900 front of 1' => null, ], 'back of 1' => [ 'back of 1' => null, 'back of 1 Asia/Tokyo' => null, 'Asia/Tokyo back of 1' => null, 'back of 1 +0900' => null, '+0900 back of 1' => null, ], ]; // Temporarily Change computer time into 23:30:00 UTC. exec('net start w32time'); exec('tzutil /s "UTC"'); exec('time 23:30:00'); // Test it. array_walk_recursive($list, function (&$v, $k) { $v = (new \DateTime($k))->format('Y-m-d H:i:s e'); }); // Recover computer time. exec('tzutil /s "Tokyo Standard Time"'); exec('w32tm /resync'); exec('net stop w32time'); // Output results. print_r($list); ?> Expected result: ---------------- Array ( [now] => Array ( [now] => 2015-03-04 23:30:00 UTC [now Asia/Tokyo] => 2015-03-05 08:30:00 Asia/Tokyo [Asia/Tokyo now] => 2015-03-05 08:30:00 Asia/Tokyo [now +0900] => 2015-03-04 23:30:00 +09:00 [+0900 now] => 2015-03-04 23:30:00 +09:00 ) [next hour] => Array ( [next hour] => 2015-03-05 00:30:00 UTC [next hour Asia/Tokyo] => 2015-03-05 09:30:00 Asia/Tokyo [Asia/Tokyo next hour] => 2015-03-05 09:30:00 Asia/Tokyo [next hour +0900] => 2015-03-05 00:30:00 +09:00 [+0900 next hour] => 2015-03-05 00:30:00 +09:00 ) [front of 1] => Array ( [front of 1] => 2015-03-04 00:45:00 UTC [front of 1 Asia/Tokyo] => 2015-03-05 00:45:00 Asia/Tokyo [Asia/Tokyo front of 1] => 2015-03-05 00:45:00 Asia/Tokyo [front of 1 +0900] => 2015-03-04 00:45:00 +09:00 [+0900 front of 1] => 2015-03-04 00:45:00 +09:00 ) [back of 1] => Array ( [back of 1] => 2015-03-04 01:15:00 UTC [back of 1 Asia/Tokyo] => 2015-03-05 01:15:00 Asia/Tokyo [Asia/Tokyo back of 1] => 2015-03-05 01:15:00 Asia/Tokyo [back of 1 +0900] => 2015-03-04 01:15:00 +09:00 [+0900 back of 1] => 2015-03-04 01:15:00 +09:00 ) ) Actual result: -------------- Array ( [now] => Array ( [now] => 2015-03-04 23:30:00 UTC [now Asia/Tokyo] => 2015-03-05 08:30:00 Asia/Tokyo [Asia/Tokyo now] => 2015-03-05 08:30:00 Asia/Tokyo [now +0900] => 2015-03-04 23:30:00 +09:00 [+0900 now] => 2015-03-04 23:30:00 +09:00 ) [next hour] => Array ( [next hour] => 2015-03-05 00:30:00 UTC [next hour Asia/Tokyo] => 2015-03-05 09:30:00 Asia/Tokyo [Asia/Tokyo next hour] => 2015-03-05 09:30:00 Asia/Tokyo [next hour +0900] => 2015-03-05 00:30:00 +09:00 [+0900 next hour] => 2015-03-05 00:30:00 +09:00 ) [front of 1] => Array ( [front of 1] => 2015-03-04 00:45:00 UTC [front of 1 Asia/Tokyo] => 2015-03-05 12:45:00 Asia/Tokyo # Bug [Asia/Tokyo front of 1] => 2015-03-05 00:45:00 Asia/Tokyo [front of 1 +0900] => 2015-03-04 12:45:00 +09:00 # Bug [+0900 front of 1] => 2015-03-04 00:45:00 +09:00 ) [back of 1] => Array ( [back of 1] => 2015-03-04 01:15:00 UTC [back of 1 Asia/Tokyo] => 2015-03-05 13:15:00 Asia/Tokyo # Bug [Asia/Tokyo back of 1] => 2015-03-05 01:15:00 Asia/Tokyo [back of 1 +0900] => 2015-03-04 13:15:00 +09:00 # Bug [+0900 back of 1] => 2015-03-04 01:15:00 +09:00 ) ) -- Edit bug report at https://bugs.php.net/bug.php?id=69186&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69186&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69186&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69186&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69186&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69186&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69186&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69186&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69186&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69186&r=support Expected behavior: https://bugs.php.net/fix.php?id=69186&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69186&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69186&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69186&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69186&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69186&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69186&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69186&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69186&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69186&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69186&r=mysqlcfg

« previous php.bugs (#191148) next »