$t = ' 2011-01-31 17:21:22 ';
Print_r (Array (
Date (' Y year m month ', Strtotime ($t)),
Date (' Y year m month ', Strtotime (' + 1 month ', Strtotime ($t))),
Date (' Y year m month ', Strtotime (' + 2 month ', Strtotime ($t))),
));
Exit
Why is it all March?
Reply to discussion (solution)
$t time is January 31 February not so the second element of the array is also March.
February No 31st
So January 31 plus one months will be March.
$t = ' 2011-01-28 17:21:22 '; Change to 28th Print_r (Array ( ' Y year M month ', Strtotime ($t)), date (' Y year m month ', Strtotime (' + 1 month ', Strtotime ($t))), date (' Y year m month ', Strtotime (' + 2 month ', Strtotime ($t))));
Array ( [0] = January 2011 [1] = February 2011 [2] = March 2011)
Strtotime is a feature with auto-correct date
Print_r (Array ( the date (' Y year m D Day ', Strtotime (' 2011-02-31 ')), date (' Y year m D Day ', Strtotime (' 2011-04-31 ')), Date (' Y year m D Day ', Strtotime (' 2011-06-31 ')));
Array ( [0] = March 03, 2011 [1] = May 01, 2011 [2] = July 01, 2011)