3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = 1616497508.795654549495619851562; try { print_r("Date (string) : "); var_dump($date); print_r("Date (json_encode) : "); var_dump(json_encode($date)); print_r("DateTimeImmutable::createFromFormat (string) : "); var_dump(DateTimeImmutable::createFromFormat( 'U.u', $date )); print_r("DateTimeImmutable::createFromFormat (json_encode) : "); var_dump(DateTimeImmutable::createFromFormat( 'U.u', json_encode($date) )); print_r("DateTimeImmutable::createFromFormat \"1616497508.7956545\" : "); var_dump(DateTimeImmutable::createFromFormat( 'U.u', "1616497508.7956545" )); print_r("DateTimeImmutable::createFromFormat \"1616497508.9999999\" : "); var_dump(DateTimeImmutable::createFromFormat( 'U.u', "1616497508.9999999" )); print_r("DateTimeImmutable::createFromFormat \"1616497508.99999999\" : "); var_dump(DateTimeImmutable::createFromFormat( 'U.u', "1616497508.99999999" )); } catch (\Exception $e) { var_dump($e); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Date (string) : float(1616497508.7956545) Date (json_encode) : string(18) "1616497508.7956545" DateTimeImmutable::createFromFormat (string) : object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2021-03-23 11:05:08.795700" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } DateTimeImmutable::createFromFormat (json_encode) : bool(false) DateTimeImmutable::createFromFormat "1616497508.7956545" : bool(false) DateTimeImmutable::createFromFormat "1616497508.9999999" : bool(false) DateTimeImmutable::createFromFormat "1616497508.99999999" : bool(false)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Date (string) : float(1616497508.7956545) Date (json_encode) : string(18) "1616497508.7956545" DateTimeImmutable::createFromFormat (string) : object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2021-03-23 11:05:08.795700" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } DateTimeImmutable::createFromFormat (json_encode) : bool(false) DateTimeImmutable::createFromFormat "1616497508.7956545" : bool(false) DateTimeImmutable::createFromFormat "1616497508.9999999" : bool(false) DateTimeImmutable::createFromFormat "1616497508.99999999" : bool(false)
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Date (string) : float(1616497508.7957) Date (json_encode) : string(18) "1616497508.7956545" DateTimeImmutable::createFromFormat (string) : object(DateTimeImmutable)#1 (3) { ["date"]=> string(26) "2021-03-23 11:05:08.795700" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" } DateTimeImmutable::createFromFormat (json_encode) : bool(false) DateTimeImmutable::createFromFormat "1616497508.7956545" : bool(false) DateTimeImmutable::createFromFormat "1616497508.9999999" : bool(false) DateTimeImmutable::createFromFormat "1616497508.99999999" : bool(false)

preferences:
150.27 ms | 403 KiB | 153 Q