xref: /PHP-8.0/ext/date/tests/bug40743.phpt (revision e549873c)
1--TEST--
2Bug #40743 (DateTime ignores the TimeZone object passed to the constructor)
3--FILE--
4<?php
5$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
6echo $dt->format(DATE_RFC822), "\n";
7echo $dt->format('T e Z'), "\n";
8echo "-----\n";
9
10date_default_timezone_set('America/New_York');
11
12$dt = new DateTime('16 Jan 08 13:04:59');
13echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
14
15$dt = new DateTime('@1200506699');
16echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
17
18$dt = new DateTime('@1200506699');
19$dt->setTimezone( new DateTimeZone( 'America/New_York' ) );
20echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
21
22$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
23echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
24
25$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago');
26echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
27
28$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago', new DateTimeZone('Europe/Berlin'));
29echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
30?>
31--EXPECT--
32Wed, 16 Jan 08 18:04:59 +0000
33GMT+0000 +00:00 0
34-----
35Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
36Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
37Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
38Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
39Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
40Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
41