Reputation: 87
I am trying to add months to a date
for ($i=0;$i<$months;$i++)
{
$newdate = strtotime ( "+1 month", strtotime ( $date ) );
$newdate = date ( 'Y-m-j' , $newdate );
}
how to get the $i inside the function?
Upvotes: 0
Views: 35
Reputation: 374
that is one possible solution
for ($i=1;$i<=$months;$i++)
{
$newdate = strtotime ( "+".$i." month", strtotime ( $date ) );
$newdate = date ( 'Y-m-j' , $newdate );
}
Upvotes: 1