Beginner JavaScript Tutorial - 37 - Date Objects

0 Alexander Best · May 31, 2014
Need help this one does not work,


<!doctype html >


<html lang="eng">
<head>
<script type="text/javascript">


function printTime(){   /*--Tengo un error en este codigo no me da la hora--*/
var now   = new Date();
var hours         = now.getHours();
var mins          = now.getMinutes();
var seconds       = now.getSeconds();


document.write(hours+":"+mins+":"seconds+"<br />");
document.write


}


setInterval("printTime()",1000);


</script>
</body>
</html>




Post a Reply

Replies

Oldest  Newest  Rating
+1 Ethan Fraser · June 1, 2014
You forget a plus symbol.
Your code:

document.write(hours+":"+mins+":"seconds+"<br />");
document.write


Code that works:

document.write(hours+":"+mins+":"+seconds+"<br />");

0 Ethan Fraser · June 3, 2014
No problem, if you have any more questions just ask, I'm happy to help :)
0 Steven the awesome · June 3, 2014
Btw use the code tags
0 Preethy B · October 4, 2015
Thank you guys!
0 Alexander Best · June 2, 2014
Ethan Fraser  Thank I see , I got it now.
  • 1

Javascript

107,000 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators