logo
Search
showing results for - "updating clock javascript"
Sofia
07 Jan 2021
1function updateTime(){
2    var currentTime = new Date()
3    var hours = currentTime.getHours()
4    var minutes = currentTime.getMinutes()
5    if (minutes < 10){
6        minutes = "0" + minutes
7    }
8    var t_str = hours + ":" + minutes + " ";
9    if(hours > 11){
10        t_str += "PM";
11    } else {
12        t_str += "AM";
13    }
14    document.getElementById('time_span').innerHTML = t_str;
15}
16setInterval(updateTime, 1000);
source
similar questions
javascript date for 5 seconds from nowjavascript load at window loading timedate to seconds jsthree js clockjavascript get clock time in auto counter upjavascript detect time on pagejavascript refresh page every 30 secondsjavascript date countdowncountdown in jsjs timer reload pagelive clock javascripthow to set timer in javascripthow to trigger events when the document loads in jshow to add seconds to time in jsjavascript program for analog clockjavascript countdown 10 secondshow to display countdown timer in javascripthow to count seconds in javascriptjs date istodaytiming code in javascriptjs add seconds to current time
queries leading to this page
how to make an updating clock on javascriptupdate javascript clock with set timeupdate javascript clock from set timeupdating clock javascripthow to make a clock in javascript that constantly updatesupdating clock javascript
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue