How to insert current time in html using javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to insert current time in html using javascript?

HTML css js

3rd Oct 2017, 8:47 AM
mithilesh pradhan
mithilesh pradhan - avatar
2 Answers
+ 1
Date.prototype.timeNow = function () { return ((this.getHours() < 10)?"0":"") + this.getHours() +":"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +":"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); } var date = new Date(); date.timeNow();
3rd Oct 2017, 9:31 AM
Calviղ
Calviղ - avatar