Jump to content


Photo

Need advice on date input


  • Please log in to reply
2 replies to this topic

#1 warpdesign

warpdesign
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 08 September 2006 - 04:48 PM

I'm creating an appointment application that the user inputs the dates of events. I created the interface as pull down menus so there are seven pull downs like so:
-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...



#2 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 08 September 2006 - 04:51 PM

As long as you have the day, date and year your user does not need to input the actual day. You can echo that information out of php.

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.

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 08 September 2006 - 04:57 PM

http://www.rainfores...etimepicker.htm

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.
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users