时间:2021-07-01 10:21:17 帮助过:13人阅读
'; echo '今天是:'.getWeekName(time(),'礼拜'); echo '
'; echo '2010-12-12是:'.getWeekName(strtotime('2010-12-12'),'礼拜'); ?>
'year', '个月'=>'month', '周'=>'week', '天'=>'day', '小时'=>'hour', '分钟'=>'minute', '秒'=>'second' ); foreach ( $unitArr as $cn => $u ) { if ( $$u > 0 ) { $elapse = $$u . $cn; break; } } return $elapse; } $past = 2052345678; // 发布日期 $now = time(); // 当前日期 $diff = $now - $past;//相差值 echo '发表于' . time2Units($diff) . '前'; ?>
function time_tran($the_time){ $now_time = date("Y-m-d H:i:s",time()+8*60*60); $now_time = strtotime($now_time); $show_time = strtotime($the_time); $dur = $now_time - $show_time; if($dur < 0){ return $the_time; }else{ if($dur < 60){ return $dur.'秒前'; }else{ if($dur < 3600){ return floor($dur/60).'分钟前'; }else{ if($dur < 86400){ return floor($dur/3600).'小时前'; }else{ if($dur < 259200){//3天内 return floor($dur/86400).'天前'; }else{ return $the_time; } } } } } }
function getTime( $val ){ if($val>0){ $nTime['nDay'] = (int)($val/(3600*24)); $nTime['nHour'] = (int)($val%(3600*24)/3600); $nTime['nMin'] = (int)($val%(3600*24)%3600/60); $nTime['nSec'] = (int)($val%(3600*24)%3600%60); } return $nTime ; } function getStrTime( $val ){ $aTime = getTime($val); $dtoc = array('nDay'=>'天','nHour'=>'小时','nMin'=>'分','nSec'=>'秒'); if( $aTime ){ foreach( $aTime as $k=>$v){ if($v){ $cTime .= $v.$dtoc[$k]; } } }else{ $cTime = '已结止'; } return $cTime; }