I am trying to create a simple clock with javascript in 24-hour format. As far as i've come i only managed to get a 12-hour format. The script is really simple actually, here what i've got:
<div id="updatetime"></div>
<script>
setInterval(function(){
var d = new Date();
var curr_hour = d.getHours();
var curr_minute = d.getMinutes() + 1;
document.getElementById("updatetime").innerHTML = curr_hour + ":" + curr_minute;
}, 1000);
</script>
as for my question: How do i convert the 12-hour output to a 24-hour output while still keeping it simple. Only the hours and minutes are needed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…