Bug #69186 [Opn->Csd]: Unexpected behavior using 'back of' or 'front of' with timezone specification

From: Date: Fri, 01 Oct 2021 14:36:30 +0000
Subject: Bug #69186 [Opn->Csd]: Unexpected behavior using 'back of' or 'front of' with timezone specification
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236967@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69186&edit=1 ID: 69186 Updated by: cmb@php.net Reported by: ryosuke_i_628 at yahoo dot co dot jp Summary: Unexpected behavior using 'back of' or 'front of' with timezone specification -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Windows 7 PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This issue is fixed as of PHP 5.6.32[1]. [1] <https://3v4l.org/s3HtM> Previous Comments: ------------------------------------------------------------------------ [2015-03-04 16:35:52] ryosuke_i_628 at yahoo dot co dot jp 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 this bug report at https://bugs.php.net/bug.php?id=69186&edit=1

« previous php.bugs (#236967) next »