This should work:
example start/end dates
$startdate = ( time() - 3587 );
$enddate = time();
difference between the two in seconds
$time_period = ( $enddate - $startdate );
$days = 0;
$hours = 0;
$minutes = 0;
$seconds = 0;
$time_increments = array( 'Days' => 86400,
'Hours' => 3600,
'Minutes' => 60,
'Seconds' => 1 );
will hold our values for ( day, minute, hour, seconds )
$time_span = array();
cycle through time_increments
while( list( $key, $value ) = each( $time_increments )) {
$this_value = (int) ( $time_period / $value );
$time_period = ( $time_period % $value );
save value
$time_span[$key] = $this_value;
}
show results
while( list( $key, $value ) = each( $time_span )) {
print "$key $value<br>\n";
}
HTH
Stew