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();

 

posted @ 2019-07-25 09:51  china/xin  阅读(4661)  评论(0编辑  收藏  举报