note 18918 deleted from function.mktime by hholzgra
| From: | hholzgra@php.net | Date: | Sun, 14 Apr 2002 21:56:15 +0000 |
| Subject: | note 18918 deleted from function.mktime by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-29322@lists.php.net to get a copy of this message | ||
Simple way to compare dates using mktime()
// Get your timestamp. In this example I'm adding 10 days to the timestamp
$getts = mktime("","","",$month,$day+10,$year);
// using the new timestamp get a date array
$add_dt_array = getdate($getts);
// get parts
$month = $add_dt_array["mon"];
$day = $add_dt_array["mday"];
$year = $add_dt_array["year"];
// format
$end_date = $month."/".$day."/".$year;
// Next, get the current timestamp
$getNow = mktime(0,0,0,date("m"),date("d"),date("Y"));
$now_dt_array = getdate($getNow);
// get parts
$month = $now_dt_array["mon"];
$day = $now_dt_array["mday"];
$year = $now_dt_array["year"];
// format
$now_date = $month."/".$day."/".$year;
if($now_date > $end_date)
{
$results .= "Expired";
} else {
$results .= "somethingelse";
}