|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-01-08 15:20 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-01-08 15:20 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 23:00:01 2025 UTC |
Description: ------------ I think this is just a small bug. "W" use ISO-8601 standard and this is enable the following: W01 can start at last year. (Ex. 2020W01 = 2019-12-30 - 2020-01-05) In this case when I want to get week number - with year information - based on the first day of the week, I get wrong year information. I tested this with PHP 7.4.0. Everything comes from php.net without any special modules or extensions. You can reproduce the issue with the "Test script". Test script: --------------- $date_string = '2020W01'; $from = date('Y-m-d', strtotime($date_string)); $to = date('Y-m-d', strtotime($date_string . '7')); echo $from .' - '. $to .'<br/>'; $from = date('Y-W', strtotime($date_string)); $to = date('Y-W', strtotime($date_string .'7')); echo $from .' - '. $to .'<br/>'; $from = date('Y-W', mktime(0,0,0,12,30,2019)); echo $from; Expected result: ---------------- 2019-12-30 - 2020-01-05 2020-01 - 2020-01 2020-01 Actual result: -------------- 2019-12-30 - 2020-01-05 2019-01 - 2020-01 2019-01