How to subtract a month through a loop to a certain date

Am trying to check if a certain event occurred every 10th of the month backwards to a specific date. Below is what i have tried but doesn’t seem to work

$lastsaving = date("2014-7-10");
$fromDate = date('Y-m-10');

while($lastsaving <= $fromDate){


$fromDate = date('$fromDate', strtotime("-1 months"));



}

if i execute

$fromDate = date('2015-06-10', strtotime("-1 months"));

the result is

2015-05-

meaning the subtraction part works perfectly but when i exchange 2015-06-10 with $fromDate and place the code in a while loop it doesn’t work. Please help me to debug


Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.