Page 1 of 1

How to compare - One month

Posted: Fri Jul 03, 2009 3:46 pm
by r_amin
I just want to know is the database date, One month old or not?

Code: Select all

 
    $todt = date("Y-m-d"); //Today
    $dbdt = date("Y-m-d", strtotime($row["date"]));//Database date
 

Code: Select all

 $expiry = $todt - one month;
How to minus 1 month

Code: Select all

 
if ($expiry > $today) { 
$new_status = "Expire"; 
} else { 
$new_status = "ok"; 
}
Please tell me how to calculate minus 1 month.
Or
any other way to compare 1 month (One month old or not).

Re: How to compare - One month

Posted: Fri Jul 03, 2009 3:55 pm
by jackpf

Code: Select all

$months = array(
'January'   => 31,
'February'  => ((date('L') == 1) ? 29 : 28),
'March'     => 31,
'April'     => 30,
'May'       => 31,
'June'      => 30,
'July'      => 31,
'August'    => 31,
'September' => 30,
'October'   => 31,
'November'  => 30,
'December'  => 31)
);
 
 
$one_month = 60 * 60 * 24 * $months[date('F')];
Like that?