I have been trying to get the timer set with the mention date and time. Below is the code i tried so far.
function timer() {
var now = new Date();
var outStr = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
document.getElementById('clockDiv').innerHTML = outStr;
setTimeout('timer()', 1000);
}
timer();
<html>
<head><title></title></head>
<body onload="timer();">
<div id="clockDiv"></div>
</body>
</html>
The above code gives the output of system date but i want to specify the date and the timer should start from that day itself.
Example: I tried adding date and time in the new date() as below:
var now = new Date('Wed, 15 May 2013 13:05:32');
But then the timer doesn't work.
Could someone please help me out here?
Aucun commentaire:
Enregistrer un commentaire