javascript setInterval()

js:

setInterval(function () {
var currentdate = new Date();
var datetime = currentdate.getDate() + "/" + (currentdate.getMonth() + 1) + "/" + currentdate.getFullYear() + " @ " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds();

var target_matches = document.querySelectorAll('.target-timeout');
target_matches[0].innerHTML = datetime;
}, 1000);

html:

update date and time every second

			

Leave a Reply

Your email address will not be published. Required fields are marked *