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