Advertisement
aliakbarbeda2

Bileueng umu MBA

Sep 14th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <style>
  5. .countup {
  6. text-align: center;
  7. margin-bottom: 20px;
  8. }
  9. .countup .timeel {
  10. display: inline-block;
  11. padding: 10px;
  12. background: #151515;
  13. margin: 0;
  14. color: white;
  15. min-width: 2.6rem;
  16. margin-left: 13px;
  17. border-radius: 10px 0 0 10px;
  18. }
  19. .countup span[class*="timeRef"] {
  20. border-radius: 0 10px 10px 0;
  21. margin-left: 0;
  22. background: #e8c152;
  23. color: black;
  24. }
  25. </style>
  26. <div class="countup" id="countup1">
  27. <span class="timeel days">00</span>
  28. <span class="timeel timeRefDays">days</span>
  29. <span class="timeel hours">00</span>
  30. <span class="timeel timeRefHours">hours</span>
  31. <span class="timeel minutes">00</span>
  32. <span class="timeel timeRefMinutes">minutes</span>
  33. <span class="timeel seconds">00</span>
  34. <span class="timeel timeRefSeconds">seconds</span>
  35. </div>
  36.  
  37. <script>
  38. /*
  39. * Basic Count Up from Date and Time
  40. * Author: @mrwigster / https://guwii.com/bytes/count-date-time-javascript/
  41. */
  42. window.onload = function() {
  43. // Month Day, Year Hour:Minute:Second, id-of-element-container
  44. countUpFromTime("2010-04-16T14:56:38+0000", 'countup1'); // ****** Change this line!
  45. };
  46. function countUpFromTime(countFrom, id) {
  47. countFrom = new Date(countFrom).getTime();
  48. var now = new Date(),
  49. countFrom = new Date(countFrom),
  50. timeDifference = (now - countFrom);
  51.  
  52. var secondsInADay = 60 * 60 * 1000 * 24,
  53. secondsInAHour = 60 * 60 * 1000;
  54.  
  55. days = Math.floor(timeDifference / (secondsInADay) * 1);
  56. hours = Math.floor((timeDifference % (secondsInADay)) / (secondsInAHour) * 1);
  57. mins = Math.floor(((timeDifference % (secondsInADay)) % (secondsInAHour)) / (60 * 1000) * 1);
  58. secs = Math.floor((((timeDifference % (secondsInADay)) % (secondsInAHour)) % (60 * 1000)) / 1000 * 1);
  59.  
  60. var idEl = document.getElementById(id);
  61. idEl.getElementsByClassName('days')[0].innerHTML = days;
  62. idEl.getElementsByClassName('hours')[0].innerHTML = hours;
  63. idEl.getElementsByClassName('minutes')[0].innerHTML = mins;
  64. idEl.getElementsByClassName('seconds')[0].innerHTML = secs;
  65.  
  66. clearTimeout(countUpFromTime.interval);
  67. countUpFromTime.interval = setTimeout(function(){ countUpFromTime(countFrom, id); }, 1000);
  68. }
  69. </script>
  70.  
  71. </body>
  72. </html>
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement