You are here: Re: To Get a Date into MySql: there must be a better way. « PHP Programming Language « IT news, forums, messages
Re: To Get a Date into MySql: there must be a better way.

Posted by Scott on 03/12/06 06:01

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.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация