$d = new \DateTime("2016-02-25 19:14:10.080415");
echo floatval($d->getTimestamp() . $d->format(".u")), "
"; // 1456424050.0804
This works, but feels very akward. Is there any better way to get a floating point number of seconds from a DateTime
object? I'm looking for the same value that microtime(true)
would return for the current time.