当月第一天、最后一天、下月第一天,时间date

时间:2022-09-30 19:23:48

时间记录,不是时间戳

1  $thismonth = date('m');
2 $thisyear = date('Y');
3 $startDay = $thisyear . '-' . $thismonth . '-1';
4 $endDay = $thisyear . '-' . $thismonth . '-' . date('t', strtotime($startDay)); //当月最后一天
5 $time1 =date('Y-m-1 H:i:s',strtotime($startDay)); //当月第一天
6 $time2 = date('Y-m-d H:i:s',strtotime('+24 hour',strtotime($endDay))); //下个月月第一天
7 $monthScore =PointLog::where([['create_time','>=',$time1],['create_time','<=',$time2]])->where('userid','=',$_COOKIE['userid'])->sum('point');