Skip to content

Commit 8ea143a

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79396: DateTime hour incorrect during DST jump forward
2 parents 8e879b9 + 1d9e716 commit 8ea143a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/date/php_date.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,6 +3263,7 @@ static void php_date_time_set(zval *object, zend_long h, zend_long i, zend_long
32633263
dateobj->time->s = s;
32643264
dateobj->time->us = ms;
32653265
timelib_update_ts(dateobj->time, NULL);
3266+
timelib_update_from_sse(dateobj->time);
32663267
} /* }}} */
32673268

32683269
/* {{{ proto DateTime date_time_set(DateTime object, int hour, int minute[, int second[, int microseconds]])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test for setting Date/Time during a forward DST transition
3+
--FILE--
4+
<?php
5+
date_default_timezone_set('America/Chicago');
6+
7+
$date = new DateTime('2020-03-08 01:30:00');
8+
echo $date->setTime(2, 0)->format('Y-m-d H:i:s T/e - U') . "\n";
9+
10+
$date = new DateTime('2020-03-08 01:30:00');
11+
echo $date->setTime(2, 30)->format('Y-m-d H:i:s T/e - U') . "\n";
12+
13+
$date = new DateTime('2020-03-08 01:30:00');
14+
echo $date->setTime(3, 0)->format('Y-m-d H:i:s T/e - U') . "\n";
15+
16+
$date = new DateTime('2020-03-08 01:30:00');
17+
echo $date->setTime(1, 59, 59)->format('Y-m-d H:i:s T/e - U') . "\n";
18+
19+
?>
20+
--EXPECT--
21+
2020-03-08 03:00:00 CDT/America/Chicago - 1583654400
22+
2020-03-08 03:30:00 CDT/America/Chicago - 1583656200
23+
2020-03-08 03:00:00 CDT/America/Chicago - 1583654400
24+
2020-03-08 01:59:59 CST/America/Chicago - 1583654399

0 commit comments

Comments
 (0)