帝國cms7.2怎樣實現時間為:幾小時前、幾天前等格式
將以下代碼放到:userfun.php <?ph ?>之間
function?user_time($tm,$num)?{if($num==1){???$tm?=??strtotime($tm);}????$cur_tm?=?time();?$dif?=?$cur_tm-$tm;???$pds?=?array('秒','分鐘','小時','天','周','個月','年');???$lngh?=?array(1,60,3600,86400,604800,2630880,31570560);???for($v?=?sizeof($lngh)-1;?($v?>=?0)&&(($no?=?$dif/$lngh[$v])<=1);?$v--);?if($v?0)?$v?=?0;?$_tm?=?$cur_tm-($dif%$lngh[$v]);???$no?=?floor($no);????$x=sprintf("%d%s",$no,$pds[$v]);???return?$x."前";}列表模板調用:'.user_time($r[newstime],0).' (注:如果不會列表放代碼,請看wareelll 在11樓的提示)
內容模板調用:<?=user_time($navinfor[newstime],0)?>
新聞熱點
疑難解答