时间:2021-07-01 10:21:17 帮助过:12人阅读
php时间戳转天数的方法:首先创建一个PHP示例文件;然后通过“(time()-$v['createtime'])/86400;”方式将时间戳转为天数即可。
本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑
php 时间戳转化成天数 四舍五入 整数
public function edit() { global $_W; global $_GPC; $openid=$_W['openid']; $boards = pdo_fetchall('select b.id,b.logo,b.title,f.createtime from ' . tablename('ewei_shop_sns_board_follow') . ' f ' . ' left join ' . tablename('ewei_shop_sns_board') . ' b on f.bid = b.id ' . ' where f.uniacid=:uniacid and f.openid=:openid ', array(':uniacid' => $_W['uniacid'], ':openid' => $openid)); $boards = set_medias($boards, 'logo'); include $this->template(); } //html 代码 <div class="mtvc mm"> {loop $boards $k $v} <div> <img class="mui-media-object mui-pull-left" src="{$v['logo']}"> <div class="mui-media-body"> {$v['title']} <p class='mui-ellipsis'>已坚持<span> <?php $times= (time()-$v['createtime'])/86400; // echo $times."<br>"; if( $times<1){ echo "1"; }else{ echo round("$times"); } ?> </span>天</p> <img class="mui-media-object mui-pull-right imgdel" src="../addons/ewei_shopv2/plugin/sns/static/images/btndel.png" onClick="delItem(this, id)"/></br> </div> </div> {/loop} </div>
重点
{$v['title']} =<?php echo $v['title']; ?>
round() 函数对浮点数进行四舍五入。
例子
<?php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(round(-4.60)); ?>
输出:
1 1 0 -4 -5
【推荐学习:PHP视频教程】
以上就是php时间戳怎么转天数的详细内容,更多请关注gxlcms其它相关文章!