programming-examples/js/Others/A Clock Script.js

31 lines
644 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
<HTML>
<HEAD>
<TITLE>Clock - Happy Codings :-) JavaScript Code Examples</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!--
function dateTime() {
var now = new Date();
var result = now.toLocaleString();
var tzOffset=-now.getTimezoneOffset()/60;
if(tzOffset<0)
result += " (GMT "+tzOffset+" hours)";
else
result += " (GMT +"+tzOffset+" hours)";
return result;
}
function tick() {
document.forms[0].clock.value=dateTime()
setTimeout("tick()",1000)
}
// --></SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT NAME="clock" TYPE="TEXT" SIZE="50"
VALUE="&{dateTime()};">
</FORM>
<SCRIPT LANGUAGE="JavaScript"><!--
tick()
// --></SCRIPT>
</BODY>
</HTML>