I am trying to get the time passed between two datetime strings (including milliseconds)
example:
$pageTime = strtotime(\"2012-04-23T16:08:14.9-05:00
Building on Dan Lee's answer, here's a universally working solution:
$pageTime = new DateTime("2012-04-23T16:08:14.9-05:00");
$rowTime = new DateTime("2012-04-23T16:08:16.1-05:00");
$uDiff = ($rowTime->format('u') - $pageTime->format('u')) / (1000 * 1000);
$timePassed = $rowTime->getTimestamp() - $pageTime->getTimestamp() + $uDiff;
Complete explanations:
$uDiff and convert the result in seconds by dividing by 1000 * 1000$uDiff is important and has to be the same as in the $timePassed operation.