1--TEST-- 2Bug GH-14383 (DateTime::createFromTimestamp overflowed microseconds value) 3--INI-- 4date.timezone=UTC 5--FILE-- 6<?php 7$cases = [ 8 [0.999_999_0, '0.999_999_0'], 9 [0.999_999_1, '0.999_999_1'], 10 [0.999_999_8, '0.999_999_8'], 11 [0.999_999_9, '0.999_999_9'], 12 [1.000_000_0, '1.000_000_0'], 13 [1.000_000_1, '1.000_000_1'], 14 [1.000_000_8, '1.000_000_8'], 15 [1.000_000_9, '1.000_000_9'], 16 [1.000_001_0, '1.000_001_0'], 17 [1.000_001_1, '1.000_001_1'], 18 [1.000_001_8, '1.000_001_8'], 19 [1.000_001_9, '1.000_001_9'], 20]; 21 22echo "plus:\n"; 23foreach ($cases as [$usec, $label]) { 24 echo "{$label}: "; 25 echo DateTime::createFromTimestamp($usec)->format('s.u'), "\n"; 26} 27 28echo "\nminus:\n"; 29foreach ($cases as [$usec, $label]) { 30 echo "-{$label}: "; 31 echo DateTime::createFromTimestamp(-$usec)->format('s.u'), "\n"; 32} 33?> 34--EXPECT-- 35plus: 360.999_999_0: 00.999999 370.999_999_1: 00.999999 380.999_999_8: 01.000000 390.999_999_9: 01.000000 401.000_000_0: 01.000000 411.000_000_1: 01.000000 421.000_000_8: 01.000001 431.000_000_9: 01.000001 441.000_001_0: 01.000001 451.000_001_1: 01.000001 461.000_001_8: 01.000002 471.000_001_9: 01.000002 48 49minus: 50-0.999_999_0: 59.000001 51-0.999_999_1: 59.000001 52-0.999_999_8: 59.000000 53-0.999_999_9: 59.000000 54-1.000_000_0: 59.000000 55-1.000_000_1: 59.000000 56-1.000_000_8: 58.999999 57-1.000_000_9: 58.999999 58-1.000_001_0: 58.999999 59-1.000_001_1: 58.999999 60-1.000_001_8: 58.999998 61-1.000_001_9: 58.999998 62