Re: Using a perl regex
| From: | Michal Migurski | Date: | Wed, 11 Feb 2004 18:17:51 +0000 |
| Subject: | Re: Using a perl regex | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177435@lists.php.net to get a copy of this message | ||
>I am trying to use a perl regular expression to validate a form field
>where I am allowing someone to edit a sql date-time stamp in the format
>of '2004-02-05 21:43:34'.
Just FYI, strtotime() provides date/time validation for free - check the
input using strtotime() and date('Y-m-d H:i:s') to get it in the form you
want.
An alternate, simpler PCRE would be:
'/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/'
Though note that unlike strtotime(), it won't tell you whether the date is
illegal.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html