xref: /PHP-7.1/ext/date/tests/bug48097.phpt (revision fdb2709d)
1--TEST--
2Bug #48097 (date_timezone_set function produces wrong datetime result)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$d = date_create( "Mon, 23 May 1955 00:00:00 +0200" );
8var_dump( $d );
9echo $d->format( DATE_ISO8601 ), "\n";
10echo $d->format( 'U' ), "\n\n";
11
12$d->setTimeZone( new DateTimeZone( 'Europe/Budapest' ) );
13var_dump( $d );
14echo $d->format( DATE_ISO8601 ), "\n\n";
15echo $d->format( 'U' ), "\n\n";
16--EXPECT--
17object(DateTime)#1 (3) {
18  ["date"]=>
19  string(26) "1955-05-23 00:00:00.000000"
20  ["timezone_type"]=>
21  int(1)
22  ["timezone"]=>
23  string(6) "+02:00"
24}
251955-05-23T00:00:00+0200
26-461124000
27
28object(DateTime)#1 (3) {
29  ["date"]=>
30  string(26) "1955-05-22 23:00:00.000000"
31  ["timezone_type"]=>
32  int(3)
33  ["timezone"]=>
34  string(15) "Europe/Budapest"
35}
361955-05-22T23:00:00+0100
37
38-461124000
39