xref: /PHP-7.2/ext/date/tests/bug62896.phpt (revision 674ccefc)
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--EXPECT--
34FROM TIMESTAMP, NO TZ:
352012-08-21 22:00:00 GMT+0000 (offset 0)
362012-08-21 22:00:00 GMT+0000 (offset 0)
37FROM TIMESTAMP, WITH TZ:
382012-08-22 00:00:00 CEST (offset 7200)
392012-08-22 00:00:00 CEST (offset 7200)
40FROM STRING:
412012-08-22 00:00:00 CEST (offset 7200)
422012-08-22 00:00:00 CEST (offset 7200)
43