Input Datetimepickers

Posted by

A problem that I have run into a couple of times is the concept of DateTime inputs. Granted it’s pretty easy on the back end to take a single DateTime data item, and wire it to a database of similar type, but on the front end, it’s not as easy. This post will cover a number of ways to handle date times as inputs in a user friendly way.

The first approach is to make a single field hold the information for both the date and the time. This makes sense because on the back end, that’s how the data usually is set up. You’re likely to just have a datetime field in a database, rather than both a date field and a time field. For the user, it can be a little more cumbersome if you look at it from the perspective of “the date and the time are two different things”. That cumbersome feeling can be mitigated by use of a datetimepicker. These are similar to datepickers, but also account for an entry to time as well.

Here are a list of examples of mostly javascript solutions (in no particular order):

  1. http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_datetime-local

  2. https://github.com/xdan/datetimepicker

  3. http://eonasdan.github.io/bootstrap-datetimepicker/

  4. http://www.malot.fr/bootstrap-datetimepicker/
  5. https://indrimuska.github.io/angular-moment-picker/

  6. http://sidaudhi.github.io/angular-circular-timepicker/

  7. http://logbon72.github.io/angular-material-datetimepicker/

  8. https://rawgit.com/Gillardo/bootstrap-ui-datetime-picker/master/example/index.html

  9. https://www.npmjs.com/package/angular-ui-bootstrap-datetimepicker

Alternatively, you can separate your inputs into two fields and make them work in tandem with each other. Below is a plunker example of how you can have those two separate fields and then tie them together to make a single javascript date object, all using vanilla javascript and html. DateTimePickers aren’t always straightforward, but there are many plugins that you can use to your advantage if you want more than the default html input type. Ultimately, I’d argue that it depends on the context of the application for which one is best, and that there isn’t necessarily a single best option.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.