Page 1 of 1

Converting Dates for a mysql database

Posted: Wed Apr 14, 2004 10:37 am
by gerrymac
Hi

The system that i am currrently developing has a booking form. On this booing from users will have to enter a bookstart and a bookend. However the MYSQL format for dates is YYYYMMDD. This presents a problem as on this side of the world people use the format DDMMYYYY. So users will be entering dates in that format and this leads to problems with the bookings in the database as they are in the wrong format. Does anyone know of a way in which i could convert the dates into the correct format? The fields bookstart and bookend are type DATE in the database

Thx

Gerry

Posted: Wed Apr 14, 2004 10:40 am
by JayBird
The best way to do this is to have three drop down menus, one for day, one for month, one for year.

The user selects the date they want by selecting the relevent information in each drop down.

Now, when the form is submitted, you can put the information togehter in the format you require becuase you have each piece of information separate.

I believe this is the best way so as to illimate user input errors.

Mark

Posted: Wed Apr 14, 2004 1:53 pm
by JAM
Bech100 wrote:I believe this is the best way so as to illimate user input errors.
I agree.

You can also use different text-fields, but that can still create someone mistyping DD and MM for example. [php_man]checkdate[/php_man]() might be worth looking into if you are trying out different ways.

Posted: Wed Apr 14, 2004 2:43 pm
by MarK (CZ)
Maybe a bit off-topic but isn't it better to save time as unix timestamp?

Posted: Wed Apr 14, 2004 3:30 pm
by xisle