Getting last month's date in php

前端 未结 18 750
心在旅途
心在旅途 2020-11-29 00:22

I want to get last month\'s date. I wrote this out:

$prevmonth = date(\'M Y\');

Which gives me the current month/year. I can\'t tell if I

18条回答
  •  爱一瞬间的悲伤
    2020-11-29 00:51

    Simply get last month.

    Example:

    Today is: 2020-09-02

    Code:

    echo date('Y-m-d', strtotime(date('Y-m-d')." -1 month"));
    

    Result:

    2020-08-02

提交回复
热议问题