Re: Date validation

From: Date: Fri, 20 May 2011 15:33:27 +0000
Subject: Re: Date validation
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-312973@lists.php.net to get a copy of this message
On Friday, May 20, 2011, João Cândido de Souza Neto wrote: > What about using regular expression to validate so using DateTime > object to parse it if it?s a valid date? Again, thanks. For info, I only need to know that it's a valid representation of a date on this occasion as I intend to use the MySQL CAST function to do the actual conversion within the INSERT or UPDATE SQL statement that commits the value to the underlying database. I strongly suspect that you're correct in that I should be able to use a regexp to do the validation. This could well be the catalyst that gets my sleeves rolled up, a large pot of strong, black coffee on the hob, and me finally trying that little bit harder to get my head around regular expressions! I was hoping that PHP would have an equivalent to VBScript's IsDate() function but it looks like I'll have to roll my own! Thanks again, -- Geoff

« previous php.general (#312973) next »