Im trying to do a fancy clock with HTML. But there is a part where I want to display like00 : 00
. But returns NaN
.
Here is the code:
var update;
function updateFunc() {
update = setInterval(myDate, 1000);
}
function myDate() {
var newDate = new Date();
document.getElementById("myDiv").innerHTML = newDate;
}
function updateClock() {
var update = setInterval(clockTime, 1000);
}
function clockTime() {
var hours = (new Date()).getHours();
var minutes = (new Date()).getMinutes();
var seconds = (new Date()).getSeconds();
document.getElementById("clockMins").innerHTML = minutes + ":" + seconds; //this is my problem.
}
updateFunc();
updateClock();
<div id="myDiv">#myDiv</div>
<div id="clockMins"></div>
Ps. How I can display the integers in two digits. Ex. 00, 01. 02.