php计算时分秒,非常好用,进来!!!//第一个,当您执行一件事,用了多长时间,计算开始到结束的时间差<br>
//$begin_time开始时间 $end_time 结束时间<br>
//最后得出 xx时xx分xx秒<br>
function get_timediff($begin_time,$end_time)<br>
{<br>
if($begin_time
$starttime = $begin_time;<br>
$endtime = $end_time;<br>
}else{<br>
$starttime = $end_time;<br>
$endtime = $begin_time;<br>
}<br>
<br>
//计算天数<br>
$timediff = $endtime-$starttime;<br>
$days = intval($timediff/86400);<br>
//计算小时数<br>
$remain = $timediff%86400;<br>
$hours = intval($remain/3600);<br>
//计算分钟数<br>
$remain = $remain%3600;<br>
$mins = intval($remain/60);<br>
//计算秒数<br>
$secs = $remain%60;<br>
//$res = array("day" => $days,"hour" => $hours,"min" => $mins,"sec" => $secs);<br>
return "{$hours}时{$mins}分{$secs}秒";<br>
}<br>
<br>
//第二个,当你发表了一个文章,计算多少分秒之前<br>
//$time 时间戳<br>
//最后得出 xx秒前<br>
function get_timejq($time){<br>
//计算天数<br>
$timediff = time()-$time;<br>
$days = intval($timediff/86400);<br>
if($days!=0){<br>
return $days."天前";<br>
}<br>
//计算小时数<br>
$remain = $timediff%86400;<br>
$hours = intval($remain/3600);<br>
if($hours!=0){<br>
return $hours."小时前";<br>
}<br>
//计算分钟数<br>
$remain = $remain%3600;<br>
$mins = intval($remain/60);<br>
if($mins!=0){<br>
return $mins."分钟前";<br>
}<br>
//计算秒数<br>
$secs = $remain%60;<br>
<br>
return $secs."秒前";<br>
<br>
}<br>
<br>
$time = time()-60*60*25;<br>
echo get_timejq($time);<br>
//输出1天前<br>
<br>
更多请加QQ群324098841<br>
论坛 http://bbs.flash127.com
AD:真正免费,域名+虚机+企业邮箱=0元