Re: convert date from UK to US for strtotime

From: Date: Wed, 14 Jan 2004 14:08:57 +0000
Subject: Re: convert date from UK to US for strtotime
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-174548@lists.php.net to get a copy of this message
> What I really need is to re-order the string that a user inputs, say, > 21/04/2004, so that it becomes 04/21/2004 so I can use strtotime. I use preg_match() (http://www.php.net/manual/de/function.preg-match.php): $dateuk = '21/04/2004'; preg_match("/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/", $dateuk, $m=''); $dateus = "$m[2]/$m[1]/$m[3]"; [0-9]{1,2} matches one or two numbers from 0 to 9 \/ matches / (...) the first brackets-pair will go to $m[1] the second to $m[2] ... g. martin luethi

« previous php.general (#174548) next »