当有统计每天的数据条数的时候,可以直接一句sql语句实现
比如字段updated_at是时间日期格式,那么DATE_FORMAT(updated_at,'%Y-%m-%d') as day 配合group by day 就能实现
select FROM_UNIXTIME(add_time,'%Y-%m-%d') as date, count(*) as total from exam_wechat_user group by date order by date desc limit 15;
如果是不是时间戳格式
DATE_FORMAT(create_time,'%Y-%m-%d') as day