输入两个时间戳,计算差值
strtotime($end_time)) list($start_time, $end_time) = array($end_time, $start_time); $sec = $start_time - $end_time; $sec = round($sec/60); $min = str_pad($sec%60, 2, 0, STR_PAD_LEFT); $hours_min = floor($sec/60); $min != 0 && $hours_min .= ':'.$min; return $hours_min; } /*** function get_date_different(){ var _date_1 = document.getElementById('date1').value.replace(/(^\s*)|(\s*$)/g,''); var _date_2 = document.getElementById('date2').value.replace(/(^\s*)|(\s*$)/g,''); _date_1 = new Date(_date_1); _date_2 = new Date(_date_2); var days= _date_2.getTime() - _date_1.getTime(); var time = parseInt(days / (1000 * 60 * 60 * 24)); document.getElementById('content').innerHTML = '两个日期相差 '+time+' 天!';} } **/ echo date('Y-m-j H:i:s',1380170166),'
'; echo date('Y-m-j H:i:s',time()),'
'; $t = hours_min(time(),1380170166); list($h,$m) = explode(':',$t); echo $h,'小时',$m,'分'; ?>
网页题目:输入两个时间戳,计算差值
文章分享:http://scgulin.cn/article/peeocs.html