Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q586 How can I show clocks, one showing the current time, and another showing a time 12 hours behind?

irt.org | Knowledge Base | JavaScript | Date | Q586 [ previous next ]

Q586 How can I show clocks, one showing the current time, and another showing a time 12 hours behind?

Try this:

<form>
<input name="timenow" type="text" size="8">
<input name="timethen" type="text" size="8">
</form>

<script language="JavaScript"><!--
function padout(number) { return (number < 10) ? '0' + number : number; }

function updateClocks() {
    now = new Date();
    document.forms[0].timenow.value = padout(now.getHours()) + ':' +
padout(now.getMinutes()) + ':' + padout(now.getSeconds());
    now.setTime(now.getTime() - (1000*60*60*12));
   document.forms[0].timethen.value = padout(now.getHours()) + ':' +
padout(now.getMinutes()) + ':' + padout(now.getSeconds());
    setTimeout('updateClocks()',500);
}

updateClocks();
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.