Javascript examples for Date Operation:Minute
dynamically display time
<html> <head></head> <body> <div id="timeNow"> </div> <script> (function foo(){//from w ww. ja va 2 s. c om var d = new Date(); var hours = d.getHours()*12; var clientTime = (hours ? hours : 12) + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + (hours >= 12 ? 'pm' : 'am'); console.log(clientTime); document.getElementById("timeNow").innerHTML = clientTime; setTimeout(foo, 1000); // refresh time every 1 second })(); </script> </body> </html>