Re: [Regular expression] Format string to "DD/MM/YYYY hh:mm"

From: Date: Thu, 30 Mar 2006 13:54:42 +0000
Subject: Re: [Regular expression] Format string to "DD/MM/YYYY hh:mm"
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-41642@lists.php.net to get a copy of this message
On Thursday 30 March 2006 16:49, Arie Nugraha wrote: > try this : > > $date = "30/12/1982 15:30" > > if (preg_match("/\d{2}\/\d{2}\/\d{4}\s\d{2}:\d{2}/i",$date )) { > echo "Date is valid"; > } else { > echo "Date NOT valid"; > } This is not correct since you don't check the ranges of the day digits, month digits, etc. The easiest way to check the string is to explode it by " " (space), then explode the first part by slash and the second by column, and at last check the ranges. A regular expression will be much more complex. > > hope it will help you -- Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436

Attachment: [application/pgp-signature]
« previous php.db (#41642) next »