User:Arichnad/utc clock.js

function zero(num) {return num<10 ? "0"+num : num;} var textNode; function putDateInHeading { textNode = document.createTextNode(""); var element = document.createElement('li'); element.appendChild(textNode); element.id = "pt-datetime"; var list = document.getElementById('p-personal').getElementsByTagName('ul')[0]; list.appendChild(element); } function updateTime { var date = new Date; var str = date.getUTCDate + " " + zero(date.getUTCHours) + ":" + zero(date.getUTCMinutes); textNode.nodeValue = str; var waitSeconds = 60-date.getUTCSeconds+1; window.setTimeout(updateTime, waitSeconds*1000); } function setup { putDateInHeading; updateTime; }

$(setup);