Advertisement
salmancreation

date time offer

Sep 27th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1.  
  2. // top bar coung down timer
  3. (function () {
  4. const lastDate = document.getElementById('offer_limit').getAttribute('data-limit');
  5. // Set the date we're counting down to Y M D
  6. let countDownDate = new Date(lastDate).getTime();
  7. // Update the count down every 1 second
  8. let counter = setInterval(function () {
  9. // Get today's date and time
  10. let now = new Date().getTime();
  11. // Find the distance between now and the count down date
  12. let distance = countDownDate - now;
  13. // Formate single digit to double digit
  14. // const FormatMe = (n) => (n < 10) ? '0' + n : n;
  15. // Time calculations for days, hours, minutes and seconds
  16. let days = Math.floor(distance / (1000 * 60 * 60 * 24));
  17. let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  18. let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  19. let seconds = Math.floor((distance % (1000 * 60)) / 1000);
  20. // Output the result in an element with id="offer_limit"
  21. document.getElementById("offer_limit").innerHTML = `
  22. <ul>
  23. <li>${days} <span>Days</span></li>
  24. <li>${hours} <span>Hours</span></li>
  25. <li>${minutes} <span>Minutes</span></li>
  26. <li>${seconds} <span>Seconds</span></li>
  27. </ul>
  28. `;
  29. // If the count down is over, write some text
  30. if (distance < 0) {
  31. clearInterval(counter);
  32. // document.getElementById("offer_limit").innerHTML = "EXPIRED";
  33. document.querySelector('.top_bar').style.display = "none";
  34. }
  35. }, 1000);
  36.  
  37. $(window).on('load resize orientationchange', function () {
  38. var navbar_height = $('.navbar').height();
  39. console.log(navbar_height);
  40. $('.header.header-banner').css('padding-top', 0 + navbar_height);
  41. });
  42.  
  43.  
  44. })();
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement