Hi,
I have been using the following code all 2008 , it checks if user is active, check last activation date, number of months paid, add that time to the last activation date and also check if date is grater than actual date.
It worked great until Jan 1st, when I guess there's a problem with users with active accounts on 2008 and months calculation with 2009
<?php
$myrow = mysql_fetch_array($result);
$date_activation = $myrow['start_date'];
$months = $myrow['type'];
$date_now = date("Y-m-d h:m:s", time());
$qty_years=floor($months/12);
$qty_months=$months%12;
$bits=explode("-",$date_activation);
$year=$bits[0];
$month = sprintf('%02d',$bits[1]);
$newyear=$year+$qty_years;
$newmonth=sprintf('%02d', $month+$qty_months);
$date_expires=$newyear."-".$newmonth."-".$bits[2];
if ($date_now <= $date_expires)
{
// user is active, write a cookie and say welcome
} else {
// subscription expired
}
?>
Thanks for all the help that you can provide!
(edited to change tags to
tags)