xref: /PHP-8.2/ext/date/tests/gh-124.phpt (revision 743d3780)
1--TEST--
2Test for timelib #124: Problem with large negative timestamps
3--INI--
4date.timezone=UTC
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE != 8) echo "skip this test is for 64-bit only";
8if (getenv('SKIP_ASAN')) die('skip triggers undefined behavior');
9?>
10--FILE--
11<?php
12var_dump((new DateTime("@-9223372036854775808"))->getTimestamp());
13var_dump((new DateTime('-292277022657-01-27 08:29:52 UTC'))->getTimestamp());
14var_dump((new DateTime('-292277022657-01-27 08:29:53 UTC'))->getTimestamp());
15
16var_dump((new DateTime("@9223372036854775807"))->getTimestamp());
17var_dump((new DateTime('+292277026596-12-04 15:30:07 UTC'))->getTimestamp());
18echo (new DateTime('+2512370164-01-01 00:00:00Z'))->format(DATE_RFC3339_EXTENDED);
19?>
20--EXPECT--
21int(-9223372036854775808)
22int(-9223372036854775808)
23int(-9223372036854775807)
24int(9223372036854775807)
25int(9223372036854775807)
262512370164-01-01T00:00:00.000+00:00
27