Show the clock of the website in console | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Show the clock of the website in console

I want get clock of a website server and show it in console, how can i do this?

16th Oct 2020, 2:41 PM
Ahmad Khosravani
Ahmad Khosravani - avatar
2 Answers
16th Oct 2020, 2:44 PM
Սոֆի Մովսեսյան
Սոֆի Մովսեսյան - avatar
+ 1
You can copy simply this piece of code: function printTime() { var d = new Date(); var hours = d.getHours(); var mins = d.getMinutes(); var secs = d.getSeconds(); document.getElementById("time").innerHTML = hours+":"+mins+":"+secs; document.getElementById("id_of_element").innerHTML=hours+":"+mins; } setInterval(printTime, 1); I hope I helped you 😄 Have a happy coding 🙂
16th Oct 2020, 2:59 PM
Matthew
Matthew - avatar