PHP获取上月数据及当月数据

PHP获取上月数据及当月数据

1.获取上个月第一天及最后一天
echo date(‘Y-m-01’, strtotime(’-1 month’));
echo date(‘Y-m-t’, strtotime(’-1 month’));

2.获取当月第一天及最后一天
$BeginDate=date(‘Y-m-01’, strtotime(date(“Y-m-d”)));
echo B e g i n D a t e ; e c h o d a t e ( ′ Y − m − d ′ , s t r t o t i m e ( " BeginDate; echo date('Y-m-d', strtotime(" BeginDate;echodate(Ymd,strtotime("BeginDate +1 month -1 day"));

3.使用函数及数组来获取上月数据并更新数据库成本月数据(只提取上月数据)
public function actionViewlist()
{
$time = date(‘Y-m-01’,strtotime(’-1 month’));
t i m e s = s t r t o t i m e ( times = strtotime( times=strtotime(time);
$lasttime = date(‘Y-m-t’,strtotime(’-1 month’));
l a s t t i m e s = s t r t o t i m e ( lasttimes = strtotime( lasttimes=strtotime(lasttime);
$selectModel = t h i s − > m o d e l C l a s s : : f i n d ( ) − > j o i n ( ′ j o i n ′ , ′ r f h b l e d g e r f i l e s b ′ , ′ b . i d = r f h b l e d g e r p r o . l e d g e r i d ′ ) − > s e l e c t ( ′ r f h b l e d g e r p r o . ∗ ′ ) − > w h e r e ( [ ′ < ′ , ′ r f h b l e d g e r p r o . c r e a t e d a t ′ , s t r t o t i m e ( d a t e ( " Y − m − 1 " , t i m e ( ) ) ) ] ) − > a n d W h e r e ( [ ′ > ′ , ′ d a t e ′ , this->modelClass::find() ->join('join','rf_hb_ledger_files b','b.id=rf_hb_ledger_pro.ledger_id') ->select('rf_hb_ledger_pro.*') ->where(['<','rf_hb_ledger_pro.created_at',strtotime(date("Y-m-1",time()))]) ->andWhere(['>','date', this>modelClass::find()>join(join,rfhbledgerfilesb,b.id=rfhbledgerpro.ledgerid)>select(rfhbledgerpro.)>where([<,rfhbledgerpro.createdat,strtotime(date("Ym1",time()))])>andWhere([>,date,times])
->andWhere([’<’,‘date’,$lasttimes])
->asArray()
->all();
n o w t i m e = s t r t o t i m e ( d a t e ( ′ Y − m − d ′ , t i m e ( ) ) ) ; f o r e a c h ( now_time = strtotime(date('Y-m-d',time())); foreach ( nowtime=strtotime(date(Ymd,time()));foreach(selectModel as &KaTeX parse error: Expected '}', got 'EOF' at end of input: … unset(v[‘id’]);
$v[‘created_at’] = $v[‘updated_at’] = $now_time;
}
f e i l d = a r r a y k e y s ( feild = array_keys( feild=arraykeys(selectModel[0]);
// ->db->createCommand()->insert()->execute();
KaTeX parse error: Undefined control sequence: \Yii at position 10: insert = \̲Y̲i̲i̲::app->db->createCommand()->batchInsert(HbLedgerPro::tableName(), f e i l d , feild, feild,selectModel)->execute();
return $insert;
}

你可能感兴趣的:(rageframe,php)