I am using below HTML tag:
<input type="time" />
In Chrome, Its showing PM/AM format, can we restrict to display 24 format always. I dont want to use HTML5 tag
This question is related to
html
Tested!
In Windows -> control panel -> Region -> Additional Settings -> Time -> Short Time:
Format your time as HH:mm
in the format
hh = 12 hours
HH = 24 hours
mm = minutes
tt = AM or PM
so to get the required result the format should be HH:mm and not hh:mm tt
You can't do it with the HTML5 input type. There are many libs available to do it, you can use momentjs or some other jQuery UI components for the best outcome.
In my case, it is taking time in AM and PM but sending data in 00-24 hours format to the server on form submit. and when use that DB data in its value then it will automatically select the appropriate AM or PM to edit form value.
<!DOCTYPE html>_x000D_
<html>_x000D_
<body>_x000D_
Time: <input type="time" id="myTime" value="16:32:55">_x000D_
_x000D_
<p>Click the button to get the time of the time field.</p>_x000D_
_x000D_
<button onclick="myFunction()">Try it</button>_x000D_
_x000D_
<p id="demo"></p>_x000D_
_x000D_
<script>_x000D_
function myFunction() {_x000D_
var x = document.getElementById("myTime").value;_x000D_
document.getElementById("demo").innerHTML = x;_x000D_
}_x000D_
</script>_x000D_
</body>_x000D_
</html>
_x000D_
I found that by setting value field (not just what is given below) time input will be internally converted into the 24hr format.
Source: Stackoverflow.com