note 89359 deleted from function.checkdate by danbrown
| From: | danbrown@php.net | Date: | Wed, 04 Mar 2009 17:28:07 +0000 |
| Subject: | note 89359 deleted from function.checkdate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151472@lists.php.net to get a copy of this message | ||
Note Submitter: sebagr@gmail
----
Here's a nice snippet to check if user input is valid:
<?php
$date_format = 'Y-m-d';
$input = '2009-03-03';
$input = trim($input);
$time = strtotime($input);
$is_valid = date($date_format, $time) == $input;
print "Valid? ".($is_valid ? 'yes' : 'no');
?>