php獲取當天零點的時間昨日時間的零點,並統計用戶數


 thinkphp5.1 中 wheretime() 方法使用

$todaytime=date('Y-m-d H:i:s',strtotime(date("Y-m-d"),time()));//今天零點 $oldtoday=date('Y-m-d H:i:s',strtotime($todaytime)-86400);//昨日零點
//今日粉絲數量
$fans[fans1]=Db::name('WechatFans')->whereTime('subscribe_at', '>=', $todaytime)->count();
//昨日粉絲數量
$fans[fans2]=Db::name('WechatFans')->whereTime('subscribe_at', 'between', [$oldtoday,$todaytime])->count();

$this->assign('fans',$fans);
$this->fetch();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM