[thelist] [PHP] reformat date...
Hassan Schroeder
hassan.schroeder at gmail.com
Thu Jan 25 11:14:14 CST 2007
On 1/25/07, Tris <beertastic at gmail.com> wrote:
> However, before I go home.. I have to convert:
>
> (string)3/MAY/07 --> (date for MySQL)2007-05-03
I'm sure there's multiple ways to do it, but quick'n'dirty:
$monthsByName =
array("JAN"=>"01","FEB"=>"02","MAR"=>"03","APR"=>"04","MAY"=>"05","JUN"=>"06","JUL"=>"07","AUG"=>"08","SEP"=>"09","OCT"=>"10","NOV"=>"11","DEC"=>"12");
$date = explode("/","3/MAY/07");
echo sprintf("20%02d-%s-%02d", $date[2], $monthsByName[$date[1]], $date[0]);
HTH!
--
Hassan Schroeder ------------------------ hassan.schroeder at gmail.com
More information about the thelist
mailing list