xref: /PHP-5.6/ext/date/tests/bug51393.phpt (revision a4d11883)
1--TEST--
2Bug #51393 (DateTime::createFromFormat() fails if format string contains timezone)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$dt = DateTime::createFromFormat('O', '+0800');
8var_dump($dt->getOffset());
9
10$dt = DateTime::createFromFormat('P', '+08:00');
11var_dump($dt->getOffset());
12
13$dt = DateTime::createFromFormat('O', '-0800');
14var_dump($dt->getOffset());
15
16$dt = DateTime::createFromFormat('P', '-08:00');
17var_dump($dt->getOffset());
18
19$dt = DateTime::createFromFormat('[O]', '[+0800]');
20var_dump($dt->getOffset());
21
22$dt = DateTime::createFromFormat('[P]', '[+08:00]');
23var_dump($dt->getOffset());
24
25$dt = DateTime::createFromFormat('[O]', '[-0800]');
26var_dump($dt->getOffset());
27
28$dt = DateTime::createFromFormat('[P]', '[-08:00]');
29var_dump($dt->getOffset());
30
31$dt = DateTime::createFromFormat('O', 'GMT+0800');
32var_dump($dt->getOffset());
33
34$dt = DateTime::createFromFormat('P', 'GMT+08:00');
35var_dump($dt->getOffset());
36
37$dt = DateTime::createFromFormat('O', 'GMT-0800');
38var_dump($dt->getOffset());
39
40$dt = DateTime::createFromFormat('P', 'GMT-08:00');
41var_dump($dt->getOffset());
42
43$dt = DateTime::createFromFormat('[O]', '[GMT+0800]');
44var_dump($dt->getOffset());
45
46$dt = DateTime::createFromFormat('[P]', '[GMT+08:00]');
47var_dump($dt->getOffset());
48
49$dt = DateTime::createFromFormat('[O]', '[GMT-0800]');
50var_dump($dt->getOffset());
51
52$dt = DateTime::createFromFormat('[P]', '[GMT-08:00]');
53var_dump($dt->getOffset());
54
55$dt = DateTime::createFromFormat('O', 'invalid');
56var_dump($dt);
57?>
58--EXPECT--
59int(28800)
60int(28800)
61int(-28800)
62int(-28800)
63int(28800)
64int(28800)
65int(-28800)
66int(-28800)
67int(28800)
68int(28800)
69int(-28800)
70int(-28800)
71int(28800)
72int(28800)
73int(-28800)
74int(-28800)
75bool(false)
76