xref: /PHP-7.2/ext/date/tests/bug48187.phpt (revision f1d7e3ca)
1--TEST--
2Bug #48187 (DateTime::diff() corrupting microtime() result)
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6
7// two arbitrary dates
8$date1 = new DateTime('2005-07-23');
9$date2 = new DateTime('2006-02-14');
10
11$begin_u = microtime(true);
12$begin_t = time();
13
14if (microtime(true) - $begin_u < 1) {
15    var_dump('microtime() difference less 1 second');
16} else {
17    var_dump('microtime() difference greater or equal 1 second');
18}
19
20if (time() - $begin_t < 1) {
21    var_dump('time() difference less 1 second');
22} else {
23    var_dump('time() difference greater or equal 1 second');
24}
25?>
26--EXPECTF--
27string(36) "microtime() difference less 1 second"
28string(31) "time() difference less 1 second"
29