Getting last month's date in php

前端 未结 18 782
心在旅途
心在旅途 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:29

    It's simple to get last month date

    echo date("Y-n-j", strtotime("first day of previous month"));
    echo date("Y-n-j", strtotime("last day of previous month"));
    

    at November 3 returns

    2014-10-1
    2014-10-31
    

提交回复
热议问题