Am trying to subtract one month from a date backwards to a given date. The code i have written does the subtraction but i don't know why it doesn't complete the loop. below is the code block
$date7 = date('Y-m-10');
$lastsaving = date("2013-2-9");
while($lastsaving < $date7){
$newdate = strtotime ( '-1 month' , strtotime ( $date7 ) ) ;
$date7 = date ( 'Y-m-d' , $newdate );
echo $date7;
echo "<br />";
}
result i get is
2015-05-10
2015-04-10
2015-03-10
2015-02-10
2015-01-10
2014-12-10
2014-11-10
2014-10-10
2014-09-10
2014-08-10
2014-07-10
2014-06-10
2014-05-10
2014-04-10
2014-03-10
2014-02-10
2014-01-10
2013-12-10
please help me find the reason it's not completing the loop