From: rick dot sketchy+phpnet at gmail dot com Operating system: ALL PHP version: 5.4.9 Package: Filter related Bug Type: Feature/Change Request Bug description:Recommending the addition of a new filter - Date validation and sanitization
Description: ------------ Lets assume you have a form, and you want the user to input a date. In this example, I'm going to use a UK formatted date (tho a US formatted or other format of date will work. Lets say our user enters "01/12/2012" (1st Dec 2012) as their date. They hit submit on the form. Currently if you wish to validate that date, you have to first sanitize it, Then to run the checkdate function, it needs the date to be split into month, day and year. This is all well and good, but now we've got to explode our date, check the exploded content is valid, then run checkdate. Would it not be simpler to be able to do this: filter_var($_POST['date'], FILTER_SANITIZE_DATE); (A FILTER_VALIDATE_DATE) would also be handy here) This would allow you to strip out having to explode the date string and run checkdate. In the background, this would simply be doing a check to see the date format. Alternatively, some sort of function to automatically detect a date format, and convert it to the gregorian date, which obviously for a date (without a time) is the preferable end result given that it will likely be stored in this format in a database. -- Edit bug report at https://bugs.php.net/bug.php?id=63804&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63804&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63804&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63804&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63804&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63804&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63804&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63804&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63804&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63804&r=support Expected behavior: https://bugs.php.net/fix.php?id=63804&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63804&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63804&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63804&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63804&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63804&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63804&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63804&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63804&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63804&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63804&r=mysqlcfg