Need advice on date input
Posted 08 September 2006 - 04:48 PM
-Day of week- -Month- -Day- -Year- @ -Hour- : -Min- -AM/PM-
The desired input would be something like Mon, Sep 18 2006 @ 10:30 AM.
So I have a two part question, 1) is there a way to check that the date is valid? For example if the user imputs Tue, Sep 18 2006 and Sep 18 2006 is actually a Monday it should return an error. 2) is there a better way to get date input from the user? Seems like there should be some kind of calendar or something they can click on to ensure that they can't enter an invalid date but I don't want to build something like that from scratch...
Posted 08 September 2006 - 04:51 PM
I use day-month-year in seperate drop downs, then before inserting you can put it together and insert it into your database as a date.
$date = $year.'-'.$month.'-'.$day;
Hope this helps, I've never answered anyone's question before.
Posted 08 September 2006 - 04:57 PM
That solves many of the problems about choosing non-existent dates and is much 'friendlier' to humans than a multiple set of dropdowns. Then 'reformat' the input to match whatever you want in the database in the form you want it. Hint: store it as datetime so you can do sensible sorting afterward.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users