...

View Full Version : date manipulation



serap
04-06-2004, 01: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?

Thanks,
Serap

bcarl314
04-06-2004, 01:43 PM
Try this...


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

serap
04-06-2004, 02: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?

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

http://www.mysql.com/doc/en/Date_and_time_functions.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum