How can I change the format of input type="time"
to 24 hours?
I searched for the HTML5 tags but there is no one that I need.
How can I change the format of input type="time"
to 24 hours?
I searched for the HTML5 tags but there is no one that I need.
As easy as this (⚠ if you have the computer in 24h
format and use Chrome):
<input type="time"/>
Note: It is very new and is not supported even in Firefox or versions of Internet Explorer and Edge
Or you can use external libraries like TimePicker.js:
var timepicker = new TimePicker('time', {
lang: 'en',
theme: 'blue-grey'
});
timepicker.on('change', function(evt) {
var value = (evt.hour || '00') + ':' + (evt.minute || '00');
evt.element.value = value;
});
<script src="http://cdn.jsdelivr.net/timepicker.js/latest/timepicker.min.js"></script>
<link href="http://cdn.jsdelivr.net/timepicker.js/latest/timepicker.min.css" rel="stylesheet"/>
<div>
<input type="text" id="time" placeholder="Horas:Minutos">
</div>
You have events like:
timepicker.on('open', function(evt){
});
timepicker.on('close', function(evt){
});