Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date/Time input for an HTML Form

I'm having trouble finding an elegant way to allow for date/time input in an html form. I am thinking of having drop down menus for year, month, day, hour, minute, second, millisecond that are populated with valid entries only. I could do this by hard coding values for each drop down menu, but I'm thinking there must be a more elegant way to do this, perhaps with some already existing javascript library that I have not found yet. Any tips for getting this done?

edit: Second, and if possible, millisecond precision is needed for what I'm working on.

edit#2: After reading some of the comments, I have come to the realization that it is probably a bad idea to have drop down menus for the large range of values required by hours/minutes/seconds and especially milliseconds. I think will go with having the DatePicker prototype date chooser, along with a simple textfield for time input.

like image 452
Matthew Avatar asked Jul 20 '09 20:07

Matthew


2 Answers

This can be done quite elegantly with a Jquery plug-in called Datepicker

like image 119
tomk Avatar answered Sep 20 '22 11:09

tomk


There are many calendars which can do this, with both date and time :

  • Calendar Date Select
  • Control.DatePicker (based on PrototypeJS) my favourite, I made an enhanced version, with more features, I can share it
  • Dynarch calendar but I find it too heavy
  • and others
like image 31
Fabien Ménager Avatar answered Sep 18 '22 11:09

Fabien Ménager