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

stormist picture stormist · Apr 12, 2010 · Viewed 54k times · Source

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

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

Answer

Adnan picture Adnan · Apr 12, 2010

Hm, maybe something like this;

echo date("F 1, Y", strtotime("-6 months"));

EDIT;

if you would like to specify a custom date use;

echo date("F, 1 Y", strtotime("-6 months", strtotime("Feb 2, 2010")));