note 25970 added to function.strtotime

From: Date: Sun, 13 Oct 2002 15:53:55 +0000
Subject: note 25970 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-38018@lists.php.net to get a copy of this message
I was trying to find a code to check if a certain date is in a date range, couldn't find one so I made one. I'm not the most efficient code writer, so this might not be the best way to do it, but it seems to be the shortest. // Date Range // a# = start date, c# = end date, b# = date to check if it's in the range function month ($monthnum) { // Return month name from number. $months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); $month = $months[$monthnum]; return $month; } function date_in_range ($a1,$a2,$a3,$b1,$b2,$b3,$c1,$c2,$c3) { $a2 = month($a2); $b2 = month($b2); $c2 = month($c2); $atime = strtotime ("$a1 $a2 $a3"); $btime = strtotime ("$b1 $b2 $b3"); $ctime = strtotime ("$c1 $c2 $c3"); if ($atime <= $btime && $btime <= $ctime) { return 1; } else { return 0; } } -- http://www.php.net/manual/en/function.strtotime.php http://master.php.net/manage/user-notes.php?action=edit+25970 http://master.php.net/manage/user-notes.php?action=delete+25970 http://master.php.net/manage/user-notes.php?action=reject+25970

« previous php.notes (#38018) next »