PHP 选时间(一个月开始与结束)段查询数据
$date = \Yii::$app->request->get('time');
$date=str_replace("年","-",$date);
$date=str_replace("月","",$date);
$month_start =strtotime($date) ;
$BeginDate=date('Y-m-01', strtotime($date));
$EndDate = date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));
$month_end= strtotime("next day", strtotime($EndDate)) - 1;
if($name=='充值'){
$query = IntegralLog::find()->where(['store_id' => $this->store_id, 'user_id' => $this->user_id,'type'=>1])->andFilterWhere(['between','addtime',$month_start, $month_end]);
}
$total=Db::name('ns_member_account_records')->where('uid',$uid)->where('account_type',1)->where('create_time','between',[$month_start,$month_end])->count();
$date=str_replace("年","-",$date);
$date=str_replace("月","",$date);
$month_start =strtotime($date) ;
$BeginDate=date('Y-m-01', strtotime($date));
$EndDate = date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));
$month_end= strtotime("next day", strtotime($EndDate)) - 1;