xref: /PHP-8.0/ext/date/tests/bug73426.phpt (revision 4aeff60f)
1--TEST--
2Bug #73426 (createFromFormat with 'z' format char results in incorrect time)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$date = '2016 12:00:00 15';
8$format = 'Y H:i:s z';
9var_dump(DateTime::createFromFormat($format, $date));
10
11$date = '16 12:00:00 2016';
12$format = 'z H:i:s Y';
13var_dump(DateTime::createFromFormat($format, $date));
14var_dump(DateTime::getLastErrors());
15?>
16--EXPECTF--
17object(DateTime)#%d (%d) {
18  ["date"]=>
19  string(26) "2016-01-16 12:00:00.000000"
20  ["timezone_type"]=>
21  int(3)
22  ["timezone"]=>
23  string(3) "UTC"
24}
25bool(false)
26array(4) {
27  ["warning_count"]=>
28  int(0)
29  ["warnings"]=>
30  array(0) {
31  }
32  ["error_count"]=>
33  int(1)
34  ["errors"]=>
35  array(1) {
36    [0]=>
37    string(57) "A 'day of year' can only come after a year has been found"
38  }
39}
40