Remember
01-28-2009, 03:44 PM
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body>
<input type="button" value="Start timer!" id="timer" onclick="startTime()" >
<div id="txt"></div>
</body>
</html>
I know, it's in PHP tags but it makes it look cooler D:
Click a button, and it starts a clock.
Simple, fun for me to do.
I'll add some updates in a bit, JavaScript is more fun than I thought it would be.
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body>
<input type="button" value="Start timer!" id="timer" onclick="startTime()" >
<div id="txt"></div>
</body>
</html>
I know, it's in PHP tags but it makes it look cooler D:
Click a button, and it starts a clock.
Simple, fun for me to do.
I'll add some updates in a bit, JavaScript is more fun than I thought it would be.