现在很多网站将时间的显示都变得比较人性化,例如:某某6秒之前发表,某某在1分钟之前执行过 xx 动作等等。最近在做相关的东西于是乎也顺便自己写了一个,较为简单,仅供参考。
<p><?php</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/code/11167">
<img src="https://img.php.cn/upload/webcode/000/000/020/176519340224613.jpg" alt="游戏点卡API接口">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/code/11167">游戏点卡API接口</a>
<p>点卡API支付接口支持各大游戏类一卡通接口。优势:1、同行业点卡回收支付业务更全;2、同行业点卡回收处理速度更快;3、同行业点卡回收技术更强,支持多卡同时提交;更新内容:1、增加点卡卡密规则文档,发便开发人员根据卡密位数提交前判断;2、增加点卡api接口密钥申请教程,减少在申请过程担误的时间;3、POST传值加密措施更严谨,同行业内存在多年的不足已修复完善;</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="游戏点卡API接口">
<span>0</span>
</div>
</div>
<a href="/xiazai/code/11167" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="游戏点卡API接口">
</a>
</div>
/*<br />*function:显示某一个时间相当于当前时间在多少秒前,多少分钟前,多少小时前<br />*timeInt:unix time时间戳<br />*format:时间显示格式<br />*/<br />function timeFormat($timeInt,$format='Y-m-d H:i:s'){<br /> if(empty($timeInt)||!is_numeric($timeInt)||!$timeInt){<br /> return '';<br /> }<br /> $d=time()-$timeInt;<br /> if($d<0){<br /> return '';<br /> }else{<br /> if($d<60){<br /> return $d.'秒前';<br /> }else{<br /> if($d<3600){<br /> return floor($d/60).'分钟前';<br /> }else{<br /> if($d<86400){<br /> return floor($d/3600).'小时前';<br /> }else{<br /> if($d<259200){//3天内<br /> return floor($d/86400).'天前';<br /> }else{<br /> return date($format,$timeInt);<br /> }<br /> }<br /> }<br /> }<br /> }<br />}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号