PHP: simplest way to get the date of the month 6 months prior on the first?

前端 未结 4 1753
悲哀的现实
悲哀的现实 2021-01-01 09:09

So if today was April 12, 2010 it should return October 1, 2009

Some possible solutions I\'ve googled seem overly complex, any suggestions?

4条回答
  •  长发绾君心
    2021-01-01 09:53

    A bit hackish but works:

    modify("-" . ($date->format('j')-1) . " days");
    echo $date->format('j, F Y');
    
    ?>
    

提交回复
热议问题