File: bug75167.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (20 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--TEST--
Bug #75167 (DateTime::add does only care about backward DST transition, not forward)
--FILE--
<?php
$tz = new DateTimeZone('Europe/London'); // A timezone that has DST

$five_hours_interval = new DateInterval('PT5H');

$date = new DateTime("2014-3-30 00:00:00", $tz);

// Add five hours and subtract 5 hours. The $newDate should then equal the date.
$five_hours_later = (clone $date)->add($five_hours_interval);
$newDate = (clone $five_hours_later)->sub($five_hours_interval);

echo $date->format('c') . "\n";
echo $newDate->format('c');
?>
--EXPECT--
2014-03-30T00:00:00+00:00
2014-03-30T00:00:00+00:00