PHP-Code:
<?php
function get_timespan($c)
{
$seconds = $c % 60;
$c -= $seconds;
$minutes = $c % 3600;
$c -= $minutes;
$hours = $c % 86400;
$c -= $hours;
return array(
'days'=>$c/86400,
'hours'=>$hours/3600,
'minutes'=>$minutes/60,
'seconds'=>$seconds
);
}
$e = strtotime('+11 seconds');
print_r(get_timespan($e-time()));
$e = strtotime('+17 minutes 11 seconds');
print_r(get_timespan($e-time()));
$e = strtotime('33 hours 17 minutes 11 seconds');
print_r(get_timespan($e-time()));
$e = strtotime('+1 week 33 hours 17 minutes 11 seconds');
print_r(get_timespan($e-time()));
?>
Kommentar