var timeformat = null; var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; function padTime(x) { return (x < 10) ? '0' + x : x; } function updateTime() { var date = new Date(); var h = date.getHours(); var m = date.getMinutes(); var s = date.getSeconds(); var dd = date.getDate(); var dm = date.getMonth(); var dy = date.getFullYear(); if (timeformat == 12) // default to 24 h = (h + 11) % 12 + 1; var str_t = padTime(h) + '  ' + padTime(m) + '  ' + padTime(s); var str_d = dd + ' ' + months[dm] + ' ' + dy; document.getElementById('timeval').innerHTML = str_t; document.getElementById('dateval').innerHTML = str_d; } function startTempo() { timeformat = localStorage['timeformat']; updateTime(); setTimeout(function() { updateTime(); setInterval(updateTime, 1000) }, 1000 - (new Date()).getTime() % 1000); } window.onload = startTempo; document.addEventListener('contextmenu', function(e) { e.preventDefault() });