note 94036 added to function.date

From: Date: Tue, 13 Oct 2009 11:40:43 +0000
Subject: note 94036 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-161673@lists.php.net to get a copy of this message
Date Validation Code function validDate($date){ //replace / with - in the date $date = strtr($date,'/','-'); //explode the date into date,month and year $datearr = explode('-', $date); //count that there are 3 elements in the array if(count($datearr) == 3){ list($d, $m, $y) = $datearr; /*checkdate - check whether the date is valid. strtotime - Parse about any English textual datetime description into a Unix timestamp. Thus, it restricts any input before 1901 and after 2038, i.e., it invalidate outrange dates like 01-01-2500. preg_match - match the pattern*/ if(checkdate($m, $d, $y) && strtotime("$y-$m-$d") && preg_match('#\b\d{2}[/-]\d{2}[/-]\d{4}\b#', "$d-$m-$y")) {/*echo "valid date";*/ return TRUE;} else {/*echo "invalid date";*/ return FALSE;} } else {/*echo "invalid date";*/ return FALSE;} /*echo "invalid date";*/ return FALSE; } ---- Server IP: 202.65.157.132 Probable Submitter: 59.93.167.238 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/94036 Del: integrated -- https://master.php.net/note/delete/94036/integrated Del: useless -- https://master.php.net/note/delete/94036/useless Del: bad code -- https://master.php.net/note/delete/94036/bad+code Del: spam -- https://master.php.net/note/delete/94036/spam Del: non-english -- https://master.php.net/note/delete/94036/non-english Del: in docs -- https://master.php.net/note/delete/94036/in+docs Del: other reasons-- https://master.php.net/note/delete/94036 Reject -- https://master.php.net/note/reject/94036 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161673) next »