note 112290 added to function.checkdate

From: Date: Tue, 28 May 2013 10:45:24 +0000
Subject: note 112290 added to function.checkdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-194976@lists.php.net to get a copy of this message
Please note that you must add an @ to the beginning of checkdate otherwise an incorrect format will cause an error. For example: <?php $date='2013-1-1'; $parsed = explode('-',$date); if( @checkdate($parsed[1],$parsed[2],$parsed[0]) ) { echo 'Valid date'; } else { echo 'False, invalid date'; } ?> If you don't you will get this for invalid formats: <?php Notice: Undefined offset: 1 in C:\websites\t\checkdate.php on line 8 \r\n Notice: Undefined offset: 2 in C:\websites\t\checkdate.php on line 8 \r\n Warning: checkdate() expects parameter 3 to be long, string given in C:\websites\t\checkdate.php on line 8 \r\nFalse, invalid date ?> ---- Server IP: 94.76.225.145 Probable Submitter: 81.149.197.105 ---- Manual Page -- http://php.net/manual/en/function.checkdate.php Edit -- https://master.php.net/note/edit/112290 Del: integrated -- https://master.php.net/note/delete/112290/integrated Del: useless -- https://master.php.net/note/delete/112290/useless Del: bad code -- https://master.php.net/note/delete/112290/bad+code Del: spam -- https://master.php.net/note/delete/112290/spam Del: non-english -- https://master.php.net/note/delete/112290/non-english Del: in docs -- https://master.php.net/note/delete/112290/in+docs Del: other reasons-- https://master.php.net/note/delete/112290 Reject -- https://master.php.net/note/reject/112290 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194976) next »