website/static/time.js

29 lines
539 B
JavaScript
Raw Normal View History

var colon = ":";
2022-12-27 00:48:42 -07:00
function updateTime(){
var date = new Date()
var hours = date.getHours()
var minutes = date.getMinutes()
if (hours > 11)
var tod = " pm";
else
var tod = " am";
if (hours > 12)
2022-12-27 00:48:42 -07:00
hours = hours - 12
else if (hours == 0)
2022-12-27 00:48:42 -07:00
hours = 12
if (minutes < 10)
2022-12-27 00:48:42 -07:00
minutes = "0" + minutes
if (colon === ":")
colon = " ";
else if (colon === " ")
colon = ":";
2022-12-27 00:48:42 -07:00
var t_str = hours + colon + minutes + tod;
2022-12-27 00:48:42 -07:00
document.getElementById('time').innerHTML = t_str;
}
setInterval(updateTime, 500);