I created a watch that will be placed in the title of my site. Time does not display zero for minutes <10. For example, if the time is 10:50, it will only show 10: 5, I found a solution, but I don’t know how to implement it. Also, if there is a better way, please share.
var current;
window.onload = function () {
current = new Date();
document.getElementById("clock").innerHTML = current.getHours() + ":" + current.getMinutes();
This is what I need
if (minutes < 10)
minutes = "0" + minutes
and this is a container for my watch
<span id="clock"> </span>
source
share