xref: /PHP-8.1/ext/date/tests/gh7758.phpt (revision 818b46ac)
1--TEST--
2Bug GH-7758 (Problems with negative timestamps and fractions)
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6
7foreach ([0.4, 0, -0.4, -1, -1.4] as $ts) {
8    $date = new DateTime('@' . $ts);
9    print_r($date);
10}
11?>
12--EXPECT--
13DateTime Object
14(
15    [date] => 1970-01-01 00:00:00.400000
16    [timezone_type] => 1
17    [timezone] => +00:00
18)
19DateTime Object
20(
21    [date] => 1970-01-01 00:00:00.000000
22    [timezone_type] => 1
23    [timezone] => +00:00
24)
25DateTime Object
26(
27    [date] => 1969-12-31 23:59:59.600000
28    [timezone_type] => 1
29    [timezone] => +00:00
30)
31DateTime Object
32(
33    [date] => 1969-12-31 23:59:59.000000
34    [timezone_type] => 1
35    [timezone] => +00:00
36)
37DateTime Object
38(
39    [date] => 1969-12-31 23:59:58.600000
40    [timezone_type] => 1
41    [timezone] => +00:00
42)
43