I have some code that I use on my site to calculate an expiry date one month from today.
$date = date("Y-m-d");// current date
$expiryDate = date( 'Y,m,d', strtotime( '+1 month' ) );
I want to be able to use a variable for the number of months
$numMonthsFree
I would be grateful for advice on how to adapt my code to use this variable to calculate the expiryDate.
I am sure there is a better way than doing this
$numMonthsFree = 3;
$date = date("Y-m-d");// current date
for ($number = 1; $number < $numMonthsFree; $number++) {
$date = date( 'Y,m,d', strtotime( '+1 month' ) );
}
$expiryDate = $date;
Thanks as always
Paul