php countdown after the order placed

旧时模样 提交于 2020-06-09 07:03:10

问题


I have a PHP script that has function allows for the seller to choose a delivery time for his listing I finally found it in the backend it was adding days to the delivery time title EX(if I created a row in the SQL table named 20 Min it takes (20) and add to it days so when the countdown start it count from 20 days) so I changed this in PHP file in the backend

from this:


    $order_time = date("M d, Y H:i:s", strtotime($date_time . " + $add_days days"));

to this:


    $order_time = date("M d, Y H:i:s", strtotime($date_time . " + $add_hours hours"));

that's worked fine to me but i want you know to add delivery time also in minutes and days not only in hours please someone help me. Thanks!

the countdown code


       var countDownDate = new Date("").getTime();
    // Update the count down every 1 second
    var x = setInterval(function(){
      var now = new Date();
      var nowUTC = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
      var distance = countDownDate - nowUTC;
      // Time calculations for days, hours, minutes and seconds
      var days = Math.floor(distance / (1000 * 60 * 60 * 24));
      var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
      var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
      var seconds = Math.floor((distance % (1000 * 60)) / 1000);
      document.getElementById("days").innerHTML = days;
      document.getElementById("hours").innerHTML = hours;
      document.getElementById("minutes").innerHTML = minutes;
      document.getElementById("seconds").innerHTML = seconds;
      // If the count down is over, write some text s
      if (distance 
      document.getElementById("countdown-heading").innerHTML = "You Failed To Deliver Your Order On Time";
      
        document.getElementById("countdown-heading").innerHTML = "Your Seller Failed To Deliver Your Order On Time";
      
      $("#countdown-timer .countdown-number").addClass("countdown-number-late");
      document.getElementById("days").innerHTML = "The";
      document.getElementById("hours").innerHTML = "Order";
      document.getElementById("minutes").innerHTML = "is";
      document.getElementById("seconds").innerHTML = "Late!";
      }
    }, 1000);

来源:https://stackoverflow.com/questions/62137294/php-countdown-after-the-order-placed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!