Re: To Get a Date into MySql: there must be a better way.



Hugh,

The best solution I have found is to use a javascript calendar to assign the value to the date field. It's easy for the users, and ensures you get the date in the format you want. The other option is to have a month, day, and year dropdown for them to select from.

It's a bit of extra work, but only the first time. If you write the code in a reusable manner, it will save you countless hours down the road. In fact, there are several javascript calendars out there which may be ideal for your situation.

There was mention of using strtotime(), which could work. It basically returns either a timestamp or false. However, the javascript method would give you more consistent results, IMO.

Scott

hugh webster wrote:
MySql seems to only accept dates as 'yyyy-mm-dd'. How do I do that when the user might input dd/mm/yy, or d.m.yyyy (I'm in Europe)? I know I can do sscanf, or explode to rebuild the date string - but there must be a better way. Is there a FAQ somwhere?

tks.

.