Bug #79580 [NEW]: date_create_from_format misses leap year

From: Date: Sun, 10 May 2020 13:22:00 +0000
Subject: Bug #79580 [NEW]: date_create_from_format misses leap year
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226976@lists.php.net to get a copy of this message
From:             mcab at acm dot org
Operating system: Linux
PHP version:      7.2.30
Package:          Date/time related
Bug Type:         Bug
Bug description:date_create_from_format misses leap year

Description:
------------
date_create_from_format when format is 'z Y' is a day out when day
number is after feb28.


Test script:
---------------
$TZ= timezone_open( "UTC" );
$refdate=date_create_from_format ( "z Y" ,"31 2020" ,$TZ );
echo date_format($refdate,"d/m/Y")."<br>";

$refdate=date_create_from_format ( "z Y" ,"60 2020" ,$TZ );
echo date_format($refdate,"d/m/Y")."<br>";

$refdate=date_create_from_format ( "z Y" ,"91 2020" ,$TZ );
echo date_format($refdate,"d/m/Y")."<br>";

$refdate=date_create_from_format ( "z Y" ,"121 2020" ,$TZ );
echo date_format($refdate,"d/m/Y")."<br>";

$refdate=date_create_from_format ( "z Y" ,"130 2020" ,$TZ );
echo date_format($refdate,"d/m/Y")."<br>";

/*  Output is 
01/02/2020
02/03/2020   <- This has missed the fact that 2020 is a leap year
02/04/2020   <- All future date are wrong
02/05/2020
11/05/2020
*/


-- 
Edit bug report at https://bugs.php.net/bug.php?id=79580&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79580&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79580&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79580&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79580&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79580&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79580&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79580&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79580&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79580&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79580&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79580&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79580&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79580&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79580&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79580&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79580&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79580&r=mysqlcfg


Thread (8 messages)

« previous php.bugs (#226976) next »