Abhishek Zirota Abhishek Zirota - 2 months ago 8
HTML Question

My Javascript isn't printing anything

My code isn't printing anything. I am trying to print current time.



<script type="text/javascript">
function print(){
var now = new Date();
var hours = now.gethours();
var seconds = now.getSeconds();
var minutes = now.getMinutes();
document.write(hours + ":" + minutes + ":" + seconds + "<br/>");
}
setInterval("print()", 1000);
</script>

Answer

Just change var hours = now.gethours(); to var hours = now.getHours();

Comments