1、打开需要显示的文件,添加下面代码。在修改前记得要备份,以免出错能够及时改回。不熟悉PHP的最好不要修改。

3、第二种方法:php获取时间间隔functiontime_tran($timeInt,$format='Y-m-dH:i:s泌驾台佐39;){$d=time()-$timeInt;if($d<0){return$timeInt;}else{if($d<60){return$d.'秒前';}else{if($d<3600){returnfloor($d/60).'分钟前';}else{if($d<86400){returnfloor($d/3600).'小时前';}else{if($d<259200){//3天内returnfloor($d/86400).'天前';}else{returndate($format,$timeInt);}}}}}}效果类似如下图

4、以上函数的方法在需要显示的地方调取并显示的代码如下:header('觊皱筠桡Content-type:text/html;charset租涫疼迟=utf-8');$d=time()-10;echotransDate($d);//显示结果将为:刚刚echo'<br/>';echotime_tran($d);//显示结果将为:10秒前
