xref: /PHP-8.1/ext/date/tests/bug41523.phpt (revision 95f4ee38)
1--TEST--
2Bug #41523 (strtotime('0000-00-00 00:00:00') is parsed as 1999-11-30) (32 bit)
3--SKIPIF--
4<?php if (PHP_INT_SIZE == 8) die("skip 32-bit only"); ?>
5--FILE--
6<?php
7date_default_timezone_set("UTC");
8
9var_dump( date_parse('0000-00-00 00:00:00') );
10var_dump( strtotime('0000-00-00 00:00:00') );
11var_dump( $dt = new DateTime('0000-00-00 00:00:00') );
12echo $dt->format( DateTime::ISO8601 ), "\n";
13
14?>
15--EXPECTF--
16array(12) {
17  ["year"]=>
18  int(0)
19  ["month"]=>
20  int(0)
21  ["day"]=>
22  int(0)
23  ["hour"]=>
24  int(0)
25  ["minute"]=>
26  int(0)
27  ["second"]=>
28  int(0)
29  ["fraction"]=>
30  float(0)
31  ["warning_count"]=>
32  int(1)
33  ["warnings"]=>
34  array(1) {
35    [20]=>
36    string(27) "The parsed date was invalid"
37  }
38  ["error_count"]=>
39  int(0)
40  ["errors"]=>
41  array(0) {
42  }
43  ["is_localtime"]=>
44  bool(false)
45}
46
47Warning: strtotime(): Epoch doesn't fit in a PHP integer in %s on line %d
48bool(false)
49object(DateTime)#1 (3) {
50  ["date"]=>
51  string(27) "-0001-11-30 00:00:00.000000"
52  ["timezone_type"]=>
53  int(3)
54  ["timezone"]=>
55  string(3) "UTC"
56}
57-0001-11-30T00:00:00+0000
58