Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function tick()
  2. {
  3. var hours, minutes, seconds, ap;
  4. var intHours, intMinutes, intSeconds;
  5. var today;
  6.  
  7. today = new Date();
  8.  
  9. intHours = today.getHours();
  10. intMinutes = today.getMinutes();
  11. intSeconds = today.getSeconds();
  12.  
  13. if (intHours == 0)
  14. {
  15. hours = "24:";
  16. ap = "AM";
  17. }
  18. else if (intHours < 24)
  19. {
  20. hours = intHours+":";
  21. ap = "AM";
  22. }
  23. else if (intHours == 24)
  24. {
  25. hours = "24:";
  26. ap = "PM";
  27. }
  28. else
  29. {
  30. intHours = intHours - 24
  31. hours = intHours + ":";
  32. ap = "PM";
  33. }
  34.  
  35. if (intMinutes < 10)
  36. {
  37. minutes = "0"+intMinutes+":";
  38. }
  39. else
  40. {
  41. minutes = intMinutes+":";
  42. }
  43.  
  44. if (intSeconds < 10)
  45. {
  46. seconds = "0"+intSeconds+" ";
  47. }
  48. else
  49. {
  50. seconds = intSeconds+" ";
  51. }
  52.  
  53. timeString = hours+minutes+seconds;
  54.  
  55. Clock.innerHTML = timeString;
  56.  
  57. window.setTimeout("tick();", 100);
  58. }
  59.  
  60. window.onload = tick;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement