note 112290 deleted from function.checkdate by googleguy
| From: | googleguy@php.net | Date: | Tue, 28 May 2013 10:47:14 +0000 |
| Subject: | note 112290 deleted from function.checkdate by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194977@lists.php.net to get a copy of this message | ||
Note Submitter: dan dot cottrell2 at gmail dot com
----
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
?>