Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to datetime-local?

Tags:

html

Is there an alternative for that because Firefox and Internet Explorer are not supporting it...

Example:

<form>
<input type="datetime-local">
</form>
like image 683
Jean-Mathieu Avatar asked Oct 21 '14 20:10

Jean-Mathieu


People also ask

Should I use datetime-local?

If the time zone is not important to your application, use datetime-local. Some browsers are still trying to catch up to the datetime input type. Firefox 7 has still not shown any progress in this area. Instead, set up your own using three select fields with options that are populated in relation to today's date.

Why datetime-local is not working in Firefox?

Input type "datetime-local" is not supported in Firefox hence it shows a text box, in this case, you can use input type as "date". As "datetime-local" shows the time as well and if you have the same requirement, you can use Input type "time" also to show the time. I hope this helps.

What format is datetime-local?

The datetime-local input uses HTML's native datetime-local picker to allow users to easily select a date and time based on their browser's locale. The internal format of all native datetime-local pickers is YYYY-MM-DDTHH:MM .


2 Answers

You can use <input type="date"> <input type="time"> together. Personally I think this is why datetime-local was removed. There are some great polyfills as well, like this one: http://afarkas.github.io/webshim/demos/index.html

like image 93
Jonathan Stegall Avatar answered Sep 18 '22 08:09

Jonathan Stegall


I ran across this while looking for something to use instead of datetime-local

https://www.daterangepicker.com/

It has similar functionality to datetime-local and some extra. The one thing you would have to account for is being able to limit users' changing the date values in the input box if you do it that way. datetime-local automatically prevents say, putting letters into the time values.

Otherwise, Jonathan's answer still seems the best basic built-in option that works with FF/Chrome.

like image 22
notsodev Avatar answered Sep 17 '22 08:09

notsodev