Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $currenttime = strtotime(date("h:i:s A"));
- $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 16 hours')));
- $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 2 weekdays'));
- if ($currenttime>$cutofftime) {
- $cutofftime+= 86400;
- $deliverydate+= 86400;
- }
- $interval = date('H:i:s', mktime(0, 0, $cutofftime-$currenttime));
- <div>For delivery on <?php echo $deliverydate; ?> order within the next <span id="time"></span> minutes!</div>
- <script>
- function startTimer(duration, display) {
- var timer = duration, hours, minutes, seconds;
- setInterval(function () {
- hours = parseInt(timer / 60, 10)
- minutes = parseInt(timer / 60, 10)
- seconds = parseInt(timer % 60, 10);
- minutes = minutes < 10 ? "0" + minutes : minutes;
- seconds = seconds < 10 ? "0" + seconds : seconds;
- display.textContent = minutes + ":" + seconds;
- if (--timer < 0) {
- timer = duration;
- }
- }, 1000);
- }
- window.onload = function () {
- var time = <?php echo $cutofftime-$currenttime; ?>,
- display = document.querySelector('#time');
- startTimer(time, display);
- };
- </script>
- <?php
- $currenttime = strtotime(date("h:i:s A"));
- $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 16 hours')));
- $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 2 weekdays'));
- if ($currenttime>$cutofftime) {
- $cutofftime = strtotime(date('h:i:s A', strtotime(date('d-m-Y') . ' + 40 hours')));
- $deliverydate = date('d-m-Y', strtotime(date('d-m-Y') . ' + 3 weekdays'));
- }
- $interval = date('H:i:s', mktime(0, 0, $cutofftime-$currenttime));
- ?>
- <div>For delivery on <?php echo $deliverydate; ?> order within the next <span id="time"></span> minutes!</div>
- <script>
- function startTimer(duration, display) {
- var timer = duration, hours, minutes, seconds;
- setInterval(function () {
- hours = parseInt(timer / 60, 10)
- minutes = parseInt(timer / 60, 10)
- seconds = parseInt(timer % 60, 10);
- minutes = minutes < 10 ? "0" + minutes : minutes;
- seconds = seconds < 10 ? "0" + seconds : seconds;
- display.textContent = minutes + ":" + seconds;
- if (--timer < 0) {
- timer = duration;
- }
- }, 1000);
- }
- window.onload = function () {
- var time = <?php echo $cutofftime-$currenttime; ?>,
- display = document.querySelector('#time');
- startTimer(time, display);
- };
- </script>
Add Comment
Please, Sign In to add comment