Bug #79081 [Opn->Nab]: Issue with date('Y-W')

From: Date: Wed, 08 Jan 2020 15:20:16 +0000
Subject: Bug #79081 [Opn->Nab]: Issue with date('Y-W')
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224781@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79081&edit=1 ID: 79081 Updated by: cmb@php.net Reported by: tomi at vipmail dot hu Summary: Issue with date('Y-W') -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: Windows PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: You have to use o instead of Y in combination with W, see <https://3v4l.org/KXUXc> and <https://www.php.net/manual/en/function.date.php#refsect1-function.date-parameters>. Previous Comments: ------------------------------------------------------------------------ [2020-01-08 13:47:01] tomi at vipmail dot hu 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79081&edit=1

« previous php.bugs (#224781) next »