Guest User

Untitled

a guest
Oct 23rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. $currenttime = strtotime(date("h:i:s A"));
  2.  
  3. $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 16 hours')));
  4.  
  5. $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 2 weekdays'));
  6.  
  7. if ($currenttime>$cutofftime) {
  8. $cutofftime+= 86400;
  9. $deliverydate+= 86400;
  10. }
  11.  
  12. $interval = date('H:i:s', mktime(0, 0, $cutofftime-$currenttime));
  13.  
  14. <div>For delivery on <?php echo $deliverydate; ?> order within the next <span id="time"></span> minutes!</div>
  15.  
  16. <script>
  17. function startTimer(duration, display) {
  18. var timer = duration, hours, minutes, seconds;
  19. setInterval(function () {
  20. hours = parseInt(timer / 60, 10)
  21. minutes = parseInt(timer / 60, 10)
  22. seconds = parseInt(timer % 60, 10);
  23.  
  24. minutes = minutes < 10 ? "0" + minutes : minutes;
  25. seconds = seconds < 10 ? "0" + seconds : seconds;
  26.  
  27. display.textContent = minutes + ":" + seconds;
  28.  
  29. if (--timer < 0) {
  30. timer = duration;
  31. }
  32. }, 1000);
  33. }
  34.  
  35. window.onload = function () {
  36. var time = <?php echo $cutofftime-$currenttime; ?>,
  37. display = document.querySelector('#time');
  38. startTimer(time, display);
  39. };
  40. </script>
  41.  
  42. <?php
  43. $currenttime = strtotime(date("h:i:s A"));
  44. $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 16 hours')));
  45. $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 2 weekdays'));
  46. if ($currenttime>$cutofftime) {
  47. $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 40 hours')));
  48. $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 3 weekdays'));
  49. }
  50. $interval = date('H:i:s', mktime(0, 0, $cutofftime-$currenttime));
  51.  
  52. ?>
  53. <div>For delivery on <?php echo $deliverydate; ?> order within the next <span id="time"></span> minutes!</div>
  54.  
  55. <script>
  56. function startTimer(duration, display) {
  57. var timer = duration, hours, minutes, seconds;
  58. setInterval(function () {
  59. hours = parseInt(timer / 60, 10)
  60. minutes = parseInt(timer / 60, 10)
  61. seconds = parseInt(timer % 60, 10);
  62.  
  63. minutes = minutes < 10 ? "0" + minutes : minutes;
  64. seconds = seconds < 10 ? "0" + seconds : seconds;
  65.  
  66. display.textContent = minutes + ":" + seconds;
  67.  
  68. if (--timer < 0) {
  69. timer = duration;
  70. }
  71. }, 1000);
  72. }
  73.  
  74. window.onload = function () {
  75. var time = <?php echo $cutofftime-$currenttime; ?>,
  76. display = document.querySelector('#time');
  77. startTimer(time, display);
  78. };
  79. </script>
Add Comment
Please, Sign In to add comment