3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "2019-08-10D00:00:03.712125000"; $parts = explode(".", $string); $microseconds = $parts[1]; $date = DateTime::createFromFormat("Y-m-d\DH:i:s", $parts[0]); $timestamp = $date->getTimestamp(); // If you want to round it to 4 decimal places // $microseconds = ltrim(round("0.".$microseconds, 4), "0."); // If you want to append the microseconds back for whichever reason // $timestamp .= ".".$microseconds; echo $timestamp;
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
1565388003
Output for 7.3.32, 7.4.26, 8.0.13
1565395203

preferences:
86.97 ms | 406 KiB | 5 Q