At 15:02 2002-02-28, you wrote:
>Hi all,
>
>I asked this question on the PHP-DB list but everyone was asleep (no
>response).
>
>=====  =====  ===== ===== ===== ===== =====
>I have a site where dates are being displayed and also entered by users. I
>don't want to offend them by asking them to use the yyyy-mm-dd format or to
>split the date into its constituent parts.

I would feel greatly appreciated if you'd allow me to enter in yyyy-mm-dd format! I've 
been using ISO format since 1971... :)


>I am displaying by using the MySQL Date_Format syntax and that's fine. I get
>dd/mm/yyyy and I want to be able to have the user enter 'dd/mm'yyyy' into a
>form and have it put into MySQL in the yyyy-mm-dd format.
>
>Now I have written a function in php to do this but I might be missing an
>easier, more elegant/efficient way of doing this.
>
>Any suggestions?

The easiest way to work around all the date formats of the world for data input on a 
web page is to simply split the input into three parts: year, month and day. Month and 
day can then be dropdown lists (built-in -partial- validation!) and depending on 
context, the year might be a dropdown list as well (good for expiration date for a CC, 
not so good for a birth date). Also, depending on context, you might be able to 
initialize the fields to the most likely or likely nearest value and save the user 
some scrolling.

For added user-friendlyness, you can add validation using JavaScript for day within 
month (dependent on year, of course) to save an extra trip to the server - but you 
need server-side validation always since not everyone uses (or can use!) JavaScript.

For special dates like birthdates other simple validations might apply.


-- 
Marjolein Katsma
HomeSite Help - http://hshelp.com/ - Extensions, Tips and Tools
The Bookstore - http://books.hshelp.com/ - Books for webmasters and webrookies


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to