Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <head>
- <meta charset="utf-8">
- <title>Write a JavaScript function to repeat a string a specified times.</title>
- </head>
- <body>
- <h1 id="showCurrentDate"></h1>
- <h1 id="showCurrentTime"></h1>
- <script>
- setInterval(function () {
- var currentDate = new Date();
- var hours = (currentDate.getHours() < 10) ? "0" + currentDate.getHours() : currentDate.getHours();
- var minutes = (currentDate.getMinutes() < 10) ? "0" + currentDate.getMinutes() : currentDate.getMinutes();
- var seconds = (currentDate.getSeconds() < 10) ? "0" + currentDate.getSeconds() : currentDate.getSeconds();
- document.getElementById("showCurrentDate").innerHTML = currentDate.getDate() + "/" + currentDate.getMonth() + 1 + "/" + currentDate.getFullYear();
- document.getElementById("showCurrentTime").innerHTML = hours + ":" + minutes + ":" + seconds;
- }, 1000);
- </script>
- </body>
Add Comment
Please, Sign In to add comment