'Calculate time difference in seconds between 2 dates PHP [duplicate]

I have to 2 dates values in PHP,

start_date_time = "2018-03-15T20:39:06Z"

end_date_time = "2018-03-17T12:42:08Z"

duration = ?  // in seconds

I actually want to get total time in seconds. Please help



Solution 1:[1]

$start_date_time  = strtotime('2011-05-12 18:20:20');
$end_date_time = strtotime('2011-05-13 18:20:20');

$durationeInSeconds = $start_date_time - $end_date_time;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dennohpeter