我正在使用一个网址的文字来计算特定时间之间的时间差,你可以在此看到:。
我刚刚指出,文字有点::当开始时间在午夜之前[请说22:30],结束时间是在午夜之后[请说:00:30],功能赢得了笔工作。
Can you help me fix that? This is the script used:
function get_time_difference( $start, $end )
{
$uts[ start ] = strtotime( $start );
$uts[ end ] = strtotime( $end );
if( $uts[ start ]!==-1 && $uts[ end ]!==-1 )
{
if( $uts[ end ] >= $uts[ start ] )
{
$diff = $uts[ end ] - $uts[ start ];
if( $days=intval((floor($diff/86400))) )
$diff = $diff % 86400;
if( $hours=intval((floor($diff/3600))) )
$diff = $diff % 3600;
if( $minutes=intval((floor($diff/60))) )
$diff = $diff % 60;
$diff = intval( $diff );
return( array( days =>$days, hours =>$hours, minutes =>$minutes, seconds =>$diff) );
}
else
{
trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING );
}
}
else
{
trigger_error( "Invalid date/time data detected", E_USER_WARNING );
}
return( false );
}