note 18918 added to function.mktime

From: Date: Sun, 10 Feb 2002 00:02:46 +0000
Subject: note 18918 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-26425@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"; } -- http://www.php.net/manual/en/function.mktime.php http://master.php.net/manage/user-notes.php?action=edit+18918 http://master.php.net/manage/user-notes.php?action=delete+18918 http://master.php.net/manage/user-notes.php?action=reject+18918

« previous php.notes (#26425) next »