Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>Digital Clock</title>
  7. </head>
  8. <body>
  9. <h1 id="clock">Clock</h1>
  10. <script type="text/javascript">
  11. function digitalClock(){
  12. var date = new Date();
  13. var hours = date.getHours() + '';
  14. var minutes = date.getMinutes() + '';
  15. var seconds = date.getSeconds() + '';
  16. var day = date.getDay();
  17. if(hours.length < 2){
  18. hours = '0' + hours;
  19. }
  20. if(minutes.length < 2){
  21. mintues = '0' + minutes;
  22. }
  23. if(seconds.length < 2){
  24. seconds = '0' + seconds;
  25. }
  26. var weekDays = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
  27. var clock = weekDays[day] + ' ' + hours + ':' + minutes + ':' + seconds;
  28. document.getElementById('clock').innerHTML = clock;
  29. console.log(clock);
  30. }
  31. digitalClock();
  32. setInterval(digitalClock,1000);
  33.  
  34.  
  35. </script>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement