Get previous month value in PHP

后端 未结 5 1778
一生所求
一生所求 2021-01-12 09:38

I have used the below PHP function to get the previous month,

$currmonth = date(\'m\', strtotime(\'-1 month\'));

It was working fine and I

5条回答
  •  既然无缘
    2021-01-12 10:26

    Literally ask strtotime for the 'first day of the previous month' this makes sure it selects the correct month:-

    $currmonth = date("m", strtotime("first day of previous month"));
    

提交回复
热议问题