Bug #78496 [Com]: date_create rolls a day back on year 0000 timestamp
| From: | alexanderpas at gmail dot com | Date: | Fri, 17 Apr 2020 06:31:54 +0000 |
| Subject: | Bug #78496 [Com]: date_create rolls a day back on year 0000 timestamp | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226630@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78496&edit=1
ID: 78496
Comment by: alexanderpas at gmail dot com
Reported by: dzuczek at dlc-solutions dot com
Summary: date_create rolls a day back on year 0000 timestamp
Status: Assigned
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 7.2.22
Assigned To: derick
Block user comment: N
Private report: N
New Comment:
This also affects getting a timestamp out of a DateTime object created with a timestamp. (Where the
output should always be the same as the input)
See https://bugs.php.net/bug.php?id=78499 which
has some additional testcases.
Previous Comments:
------------------------------------------------------------------------
[2019-09-05 23:41:52] alexanderpas at gmail dot com
ISO 8601 defines the year zero as the year 1 BC in the Gregorian calendar.
The last few days in January are also affected.
------------------------------------------------------------------------
[2019-09-05 22:12:03] requinix@php.net
Related To: Bug #78499
------------------------------------------------------------------------
[2019-09-05 16:47:38] cmb@php.net
Well, actually there is no year 0 in the Gregorian calendar.
------------------------------------------------------------------------
[2019-09-05 16:24:27] dzuczek at dlc-solutions dot com
More tests, looks like it's just February dates...
0000-01-20 00:00:00 UTC (works) https://3v4l.org/2hPTv
0000-02-20 00:00:00 UTC (fails) https://3v4l.org/manbk
0000-03-20 00:00:00 UTC (works) https://3v4l.org/SMI46
------------------------------------------------------------------------
[2019-09-05 16:02:08] dzuczek at dlc-solutions dot co
Passing a date instead of seconds does work:
https://3v4l.org/cRcKS
<?php
$date_time = date_create('0000-02-20 00:00:00 UTC');
print_r($date_time);
$date_time = date_create('0001-02-20 00:00:00 UTC');
print_r($date_time);
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78496
--
Edit this bug report at https://bugs.php.net/bug.php?id=78496&edit=1