Bug #79081 [NEW]: Issue with date('Y-W')

From: Date: Wed, 08 Jan 2020 13:47:01 +0000
Subject: Bug #79081 [NEW]: Issue with date('Y-W')
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224780@lists.php.net to get a copy of this message
From: tomi at vipmail dot hu Operating system: Windows PHP version: Irrelevant Package: Date/time related Bug Type: Bug Bug description:Issue with date('Y-W') 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 bug report at https://bugs.php.net/bug.php?id=79081&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79081&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79081&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79081&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79081&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79081&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79081&r=support Expected behavior: https://bugs.php.net/fix.php?id=79081&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79081&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79081&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79081&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79081&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79081&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79081&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79081&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79081&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79081&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79081&r=mysqlcfg

« previous php.bugs (#224780) next »