Puedes usar DateTime::diff para saber cuanto tiempo ha pasado, ejemplo:
Código PHP:
Ver originalfunction dt($fecha) {
$d1 = new DateTime($fecha);
$d2 = new DateTime('now');
$i = $d1->diff($d2);
return $i->format('%h horas %i minutos %s segundos %d días');
}
echo dt('28-09-2011 15:00:00');
Sobre tu código no puedes hacer esto
Código PHP:
Ver original//ESTO ESTA MAL, Necesitas usar funciones como strtotime para poder restar
$time_difference = $date - $session_time;
http://php.net/manual/es/datetime.diff.php http://php.net/manual/es/function.strtotime.php
Saludos.