php 時間戳記轉化成天數 四捨五入 整數

來源:互聯網
上載者:User

標籤:add   cti   4.6   ima   UI   round   clu   include   浮點   

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() 函數對浮點數進行四捨五入。

例子
<?phpecho(round(0.60));echo(round(0.50));echo(round(0.49));echo(round(-4.40));echo(round(-4.60));?>

輸出:

110-4-5

 

php 時間戳記轉化成天數 四捨五入 整數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.