note 57099 added to function.checkdate

From: Date: Fri, 23 Sep 2005 14:46:17 +0000
Subject: note 57099 added to function.checkdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-95662@lists.php.net to get a copy of this message
just a slight problem the explode function needs the $date var adding. right <?php if (count($datebits=explode('-',$date))!=3) return false; ?> orig <?php if (count($datebits=explode('-'))!=3) return false; ?> so the entire working thing with earlier array corrected is <?php function datecheck($date, $yearepsilon=5000) { if (count($datebits=explode('-',$date))!=3) return false; $month = intval($datebits[0]); $day = intval($datebits[1]); $year = intval($datebits[2]); if ((abs($year-date('Y'))>$yearepsilon) || // year outside given range ($month<1) || ($month>12) || ($day<1) || (($month==2) && ($day>28+(!($year%4))-(!($year%100))+(!($year%400)))) || ($day>30+(($m>7)^($m&1)))) return false; // date out of range return array( 'year' => $year, 'month' => $month, 'day' => $day, ); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.checkdate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57099 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57099&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57099&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#95662) next »