Given a time, how can I find the time one month ago

后端 未结 7 1517
梦如初夏
梦如初夏 2021-01-13 08:16

Given a time, how can I find the time one month ago.

7条回答
  •  旧时难觅i
    2021-01-13 08:30

    These answers were driving me nuts. You can't subtract 31 days and have a sane result without skipping short months. I'm presuming you only care about the month, not the day of the month, for a case like filtering/grouping things by year and month.

    I do something like this:

    $current_ym = date('ym',strtotime("-15 days",$ts));

提交回复
热议问题