Mazzy
Mazzy

Reputation: 14179

Which is the way to get date and time through HTML 5

I'm developing a web app where I should get time and date through a form. I have tried time but unfortunately it is not compatible with all browser. For example it doesn't work properly in Safari. So which is the best way to get date and time?

Select a time: <input type="time" name="usr_time">

this element doesn't work correctly on Safari

Upvotes: 0

Views: 65

Answers (1)

Julian Knight
Julian Knight

Reputation: 4923

The new HTML 5 input types are very poorly supported right now.

Some options:

  • You can leave the code as it is and sanity check the input with JavaScript.
  • Use two input fields as suggested by @HaukurHaf
  • Use a JavaScript library
  • Write your own JavaScript

The quickest to get right would be to use a library that uses JavaScript to attach a script to the input field giving the user a better experience with perhaps a clock or other selector to help them.

For example, the JQuery based Time Entry helper by Keith Wood.

Upvotes: 1

Related Questions