note 114780 added to datetime.sub
| From: | itonohito | Date: | Sat, 05 Apr 2014 19:25:15 +0000 |
| Subject: | note 114780 added to datetime.sub | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199191@lists.php.net to get a copy of this message | ||
When trying to pass daylight saving state change time, sub() works incorrectly.
$t = new DateTime( '2014-03-30 02:00:00' );
$t->add( new DateInterval('PT1H') );
echo $->format('Y-m-d H:i:s');
output will be: '2014-03-30 04:00:00'.
Well, it's ok because at 3:00 a.m. daylight saving time begins in my country, so after
02:59:59 must be 04:00:00.
But if I try to subtract time:
$t = new DateTime( '2014-03-30 04:00:00' );
$t->sub( new DateInterval('PT1H') );
echo $->format('Y-m-d H:i:s');
output will be: '2014-03-30 04:00:00'.
Yes, completely the same, not '2014-03-30 02:00:00' as it should be.
----
Server IP: 72.52.91.14
Probable Submitter: 37.229.12.44
----
Manual Page -- http://php.net/manual/en/datetime.sub.php
Edit -- https://master.php.net/note/edit/114780
Del: integrated -- https://master.php.net/note/delete/114780/integrated
Del: useless -- https://master.php.net/note/delete/114780/useless
Del: bad code -- https://master.php.net/note/delete/114780/bad+code
Del: spam -- https://master.php.net/note/delete/114780/spam
Del: non-english -- https://master.php.net/note/delete/114780/non-english
Del: in docs -- https://master.php.net/note/delete/114780/in+docs
Del: other reasons-- https://master.php.net/note/delete/114780
Reject -- https://master.php.net/note/reject/114780
Search -- https://master.php.net/manage/user-notes.php