网站建设企业合作邀请函,濮阳中强网站建设,百度普通下载,西安seo王发生场景
在7月31号是查看统计上个月订单购买总金额#xff0c;查询结果为0
$preMonthStart strtotime(date(Ym01, strtotime(-1 month)));
$curMonthStart strtotime(date(Ym01));
# 统计上月份实际订单金额
$sql SELECT count(money) FROM orders WH…发生场景
在7月31号是查看统计上个月订单购买总金额查询结果为0
$preMonthStart strtotime(date(Ym01, strtotime(-1 month)));
$curMonthStart strtotime(date(Ym01));
# 统计上月份实际订单金额
$sql SELECT count(money) FROM orders WHERE confirm_time {$preMonthStart} AND confirm_time {$curMonthStart}
问题排查
public function get_order_lastmomth_money(){$day strtotime(January 1, 2023);for ($i 0;$i 365;$i) {echo 当前日期.date(Ymd,$day ($i * 86400)) . -上月月初日期 . date(Ym01, strtotime(-1 Month, $day ($i * 86400))) . br /;}} 原因官网 # 官网文档PHP: strtotime - Manual strtotime(-1 month,time()); 以当前时间戳的日数据在上个月找到对应的日数据即3月01日找2月01日因此3月29号在2月份找不到29号直接往后1天即3月01号 解决官网 # first day of last month 上个月的最后一天 # strtotime(date(Ymd)) 当天的时间戳 date(Ymd,strtotime(first day of last month, strtotime(date(Ymd)))) public function get_order_lastmomth_money(){$day strtotime(January 1, 2023);for ($i 0;$i 365;$i) {echo 当前日期.date(Ymd,$day ($i * 86400)) . -上月月初日期 . date(Ymd, strtotime(first day of last month, $day ($i * 86400))) . br /;}
} 感谢阅读欢迎讨论