Guest User

Untitled

a guest
Jan 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <head>
  2. <meta charset="utf-8">
  3. <title>Write a JavaScript function to repeat a string a specified times.</title>
  4. </head>
  5. <body>
  6. <h1 id="showCurrentDate"></h1>
  7. <h1 id="showCurrentTime"></h1>
  8. <script>
  9. setInterval(function () {
  10. var currentDate = new Date();
  11. var hours = (currentDate.getHours() < 10) ? "0" + currentDate.getHours() : currentDate.getHours();
  12. var minutes = (currentDate.getMinutes() < 10) ? "0" + currentDate.getMinutes() : currentDate.getMinutes();
  13. var seconds = (currentDate.getSeconds() < 10) ? "0" + currentDate.getSeconds() : currentDate.getSeconds();
  14. document.getElementById("showCurrentDate").innerHTML = currentDate.getDate() + "/" + currentDate.getMonth() + 1 + "/" + currentDate.getFullYear();
  15. document.getElementById("showCurrentTime").innerHTML = hours + ":" + minutes + ":" + seconds;
  16. }, 1000);
  17.  
  18. </script>
  19. </body>
Add Comment
Please, Sign In to add comment