Bug #71690 [Opn]: DateTime::createFromFormat malfunctions on a leap day
| From: | stefan at forward dot cat | Date: | Mon, 29 Feb 2016 17:05:45 +0000 |
| Subject: | Bug #71690 [Opn]: DateTime::createFromFormat malfunctions on a leap day | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-199528@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71690&edit=1
ID: 71690
User updated by: stefan at forward dot cat
Reported by: stefan at forward dot cat
Summary: DateTime::createFromFormat malfunctions on a leap
day
Status: Open
Type: Bug
Package: Date/time related
PHP Version: 7.0.3
Block user comment: N
Private report: N
New Comment:
This should say:
Expected result:
----------------
A date in february
Actual result:
--------------
2015-03-01 12:21:30
Previous Comments:
------------------------------------------------------------------------
[2016-02-29 14:01:13] stefan at forward dot cat
Description:
------------
See test script, DateTime::createFromFormat("Y-m", "2015-02") creates a date in
march (March 1 2015) when run today 29/2/2016.
possibly related: https://bugs.php.net/bug.php?id=70956&edit=2
Test script:
---------------
<?php
$timezone = new DateTimeZone("UTC");
$result = DateTime::createFromFormat("Y-m", "2015-02", $timezone);
$timestamp = $result->format('U');
$date_time = date_create('@' . $timestamp);
date_timezone_set($date_time, $timezone);
echo date_format($date_time, 'Y-m-d H:i:s');
Expected result:
----------------
2015-03-01 12:21:30
Actual result:
--------------
not a date in march
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71690&edit=1