php get difference between two timestamps in seconds code example
Example 1: difference between two timestamps php
$datetime1 = new DateTime('2016-11-30 03:55:06');
$datetime2 = new DateTime('2016-11-30 11:55:06');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%Y years %m months %d days %H hours %i minutes %s seconds');
Example 2: difference of two dates in seconds php
$timeFirst = strtotime('2011-05-12 18:20:20');
$timeSecond = strtotime('2011-05-13 18:20:20');
$differenceInSeconds = $timeSecond - $timeFirst;