WEB开发网
开发学院WEB开发PHP 计算两个时间相差的天,时,分,秒 阅读

计算两个时间相差的天,时,分,秒

 2012-05-17 16:24:42 来源:WEB开发网   
核心提示:php;">$d = "2012-05-22 15:30:10";function shi_jian_cha($d,$d1){ $time = strtotime($d) - strtotime($d1); $n_time = str_pad(floor($time/3
php;">
$d = "2012-05-22 15:30:10";
function shi_jian_cha($d,$d1)
{    
    $time = strtotime($d) - strtotime($d1);	
    $n_time = str_pad(floor($time/3600/24),2,0,STR_PAD_LEFT )."天".str_pad(floor($time%(24*3600)/3600),2,0,STR_PAD_LEFT )."小时".str_pad(floor($time%3600/60),2,0,STR_PAD_LEFT)."分".str_pad($time%3600%60, 2, 0, STR_PAD_LEFT)."秒";
    return $n_time;
}

Tags:计算 两个 时间

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接