问题
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