View Full Version : date manipulation

04-06-2004, 12:20 PM
I have a problem with the dates and how to format them - both when inserting and querying from DB.

Our users uses the dates in the "29-04-2004" (dd-mm-yyyy) format. The mySQL DB needs them in the "04-29-2004" (mm-dd-yyyy) (the US format).

Is there a function in mySQL/PHP that can convert directly? OR do I need to make a string manipulation? and what do I use to convert the string f.ex "29-04-2004" into "29" and to "04". I hava a PHP manual but could not really find anything that could 'cut' strings to pieces?


04-06-2004, 12:43 PM
Try this...

$var = "29-04-2004";//Hey, that's my Birthday! :)
list($day, $month, $year) = split("-",$var);

04-06-2004, 01:13 PM
ok thanks for the tip...

Do you if is is possible to change the server date (yyyy-mm-dd) to something else in mySQL so that you dont need to make conversions each time?

04-06-2004, 01:38 PM
Check out the mysql documentation:


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum