xref: /php-src/ext/date/tests/bug64887.phpt (revision f8d79582)
1--TEST--
2Bug #64887: Allow DateTime modification with subsecond items
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$tests = [
8    '+1 ms',
9    '-2 msec',
10    '+3 msecs',
11    '-4 millisecond',
12    '+5 milliseconds',
13
14    '-6 usec',
15    '+7 usecs',
16    '-8 microsecond',
17    '+9 microseconds',
18    '-10 µs',
19    '+11 µsec',
20    '-12 µsecs',
21
22    '+8 msec -2 µsec',
23];
24
25$datetime = new DateTimeImmutable( "2016-10-07 13:25:50" );
26
27foreach ( $tests as $test )
28{
29    echo $datetime->modify( $test )->format( 'Y-m-d H:i:s.u' ), "\n";
30}
31
32?>
33--EXPECT--
342016-10-07 13:25:50.001000
352016-10-07 13:25:49.998000
362016-10-07 13:25:50.003000
372016-10-07 13:25:49.996000
382016-10-07 13:25:50.005000
392016-10-07 13:25:49.999994
402016-10-07 13:25:50.000007
412016-10-07 13:25:49.999992
422016-10-07 13:25:50.000009
432016-10-07 13:25:49.999990
442016-10-07 13:25:50.000011
452016-10-07 13:25:49.999988
462016-10-07 13:25:50.007998
47