xref: /PHP-8.4/ext/date/tests/bug62896.phpt (revision 7aacc705)
1--TEST--
2Bug #62896 Unixtimestamp may take on local times DST flag (this test will only be valid during CEST)
3--INI--
4date.timezone=Europe/Berlin
5--FILE--
6<?php
7  $tz = new DateTimeZone('Europe/Berlin');
8
9  echo "FROM TIMESTAMP, NO TZ:\n";
10
11  $date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));
12  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
13
14  $date->modify('+0 days');
15  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
16
17  echo "FROM TIMESTAMP, WITH TZ:\n";
18
19  $date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));
20  $date->setTimezone($tz);
21  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
22
23  $date->modify('+0 days');
24  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
25
26  echo "FROM STRING:\n";
27
28  $date = new DateTime('2012-08-22 00:00:00 CEST', $tz);
29  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
30
31  $date->modify('+0 days');
32  echo $date->format('Y-m-d H:i:s T').' (offset '.$date->getOffset().")\n";
33?>
34--EXPECT--
35FROM TIMESTAMP, NO TZ:
362012-08-21 22:00:00 GMT+0000 (offset 0)
372012-08-21 22:00:00 GMT+0000 (offset 0)
38FROM TIMESTAMP, WITH TZ:
392012-08-22 00:00:00 CEST (offset 7200)
402012-08-22 00:00:00 CEST (offset 7200)
41FROM STRING:
422012-08-22 00:00:00 CEST (offset 7200)
432012-08-22 00:00:00 CEST (offset 7200)
44