xref: /PHP-8.1/ext/date/tests/bug77097.phpt (revision 6c4e2079)
1--TEST--
2Bug #77097 (DateTime::diff gives wrong diff when the actual diff is less than 1 second)
3--FILE--
4<?php
5$now = new DateTime('2018-11-03 11:34:20.781751');
6$ago = new DateTime('2018-11-03 11:34:20.000000');
7
8$diff = $now->diff($ago);
9var_dump($diff->invert, $diff->s, $diff->f);
10
11$diff = $ago->diff($now);
12var_dump($diff->invert, $diff->s, $diff->f);
13
14$diff = $now->diff($ago, true);
15var_dump($diff->invert, $diff->s, $diff->f);
16
17$diff = $ago->diff($now, true);
18var_dump($diff->invert, $diff->s, $diff->f);
19?>
20--EXPECT--
21int(1)
22int(0)
23float(0.781751)
24int(0)
25int(0)
26float(0.781751)
27int(0)
28int(0)
29float(0.781751)
30int(0)
31int(0)
32float(0.781751)
33
34