I am doing a SQL to my database and then get a datetime with microseconds in return. Now I tried printing it like this:
print date("Y-m-d H:i:s.u",strtotime($order["DateTimeEnteredMicro"]));
But this resulted in 2020-12-12 06:00:39.000000.
I found this anser on stackoverflow: https://stackoverflow.com/a/17909891/10673107
But I can't get his solution to work. I used the following code:
$t = microtime(true);
$micro = date("Y-m-d H:i:s",strtotime($order["DateTimeEnteredMicro"]));
$d = new DateTime( date('Y-m-d H:i:s.'.$micro, $t) );
print $d->format("Y-m-d H:i:s.u");
The error I get is the following:
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (2020-12-12 11:42:03.2020-12-12 06:00:39) at position 31 (0): Double time specification
How can I fix this?