Bug #79580 [Opn->Ver]: date_create_from_format misses leap year

From: Date: Sun, 10 May 2020 13:41:20 +0000
Subject: Bug #79580 [Opn->Ver]: date_create_from_format misses leap year
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226977@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79580&edit=1

 ID:                 79580
 Updated by:         cmb@php.net
 Reported by:        mcab at acm dot org
 Summary:            date_create_from_format misses leap year
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        7.2.30
 Block user comment: N
 Private report:     N

 New Comment:

Confirmed: <https://3v4l.org/Drfk6>.


Previous Comments:
------------------------------------------------------------------------
[2020-05-10 13:22:00] mcab at acm dot org

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 this bug report at https://bugs.php.net/bug.php?id=79580&edit=1


Thread (8 messages)

« previous php.bugs (#226977) next »