[php]代码库
/* $time_s 现在时间
$time_n 开始时间
*/
function gettime($time_s,$time_n){
$time_s = strtotime($time_s);
$time_n = strtotime($time_n);
$str='';
$rest = $time_n - $time_s;
if($rest>= 86400){
//return $str='date("Y-m-d H:i:s",$time_s)';
$str .= intval($rest/86400).'天';
$rest = $rest % 86400;
}else{
$str .='';
}
if($rest>=3600){
$str .= intval($rest/3600).'小时';
$rest = $rest % 3600;
}else{
$str .='';
}
if($rest>=60){
$str .= intval($rest/60).'分';
$rest = $rest % 60;
}else{
$str .='';
}
if($rest>=0){
$str .= intval($rest).'秒前';
}else{
$str ="已结束";
}
//json_encode(array('hour1'=>$remain_hour,'minute1'=>$remain_minute,'second1'=>$remain_second));
return $str;
}