Bug #77788 [Opn->Fbk]: date_add returns invalid time during DST transition
| From: | requinix@php.net | Date: | Sun, 24 Mar 2019 09:37:51 +0000 |
| Subject: | Bug #77788 [Opn->Fbk]: date_add returns invalid time during DST transition | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220161@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77788&edit=1
ID: 77788
Updated by: requinix@php.net
Reported by: r dot schuil at gmail dot com
Summary: date_add returns invalid time during DST transition
-Status: Open
+Status: Feedback
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 7.2.16
Block user comment: N
Private report: N
New Comment:
What does date_default_timezone_get() return?
Previous Comments:
------------------------------------------------------------------------
[2019-03-24 09:31:39] r dot schuil at gmail dot com
Description:
------------
When the addition to date/time causes it to be within the hour of DST transition, PHP returns an
invalid date/time.
For example, 2019-01-31 02:00:12 plus two months returns 2019-03-31 02:00:12, which gets rejected by
MySQL because the 3rd hour does not exist on this date. Instead, it should return 2019-03-31
03:00:12
Test script:
---------------
<?php
$date = date_create('2019-01-31 02:00:12');
date_add($date, date_interval_create_from_date_string('2 months'));
echo date_format($date, 'Y-m-d H:i:s');
?>
Expected result:
----------------
2019-03-31 03:00:12
Actual result:
--------------
2019-03-31 02:00:12
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77788&edit=1