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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值