I would like to create a script where time which you will get depends on the day.
f it's a normal week day it should echo the current date but time < 4pm if the time is >4pm that it should echo +2 day. But if today is Friday and the is >4pm and Saturday/Sunday then it should echo Monday for friday and Saturday and Tuesday for Sunday and so there should be also a countdown like : "Order within....(depends on the minutes until tomorrow 4pm or day with 4pm)"
for ex.
Today is Monday 3pm: The customer have 1 hour to buy to get teh product on Tuesday so the code should echo: "Want it Tuesday, Jan. 28? Order within 00 hrs 57 mins"
Today is Monday 6pm: The customer have now time to buy it until tomorrow 4pm to get it Wednesday so the code should echo: "Want it Wednesday, Jan. 29? Order within 22 hrs 00 mins"
.. .. ..
Today is Friday 3pm: The customer have 1 hour to buy to get teh product on Saturday so the code should echo: "Want it Saturday, $date ? Order within 00 hrs 57 mins"
Today is Friday 5pm: The customer have 1 hour to buy to get teh product on Monday so the code should echo: "Want it Monday, $date ? Order within $timer"
Today is Saturday 3pm/6pm: The customer have now time to buy it until tomorrow 4pm to get it Monday so the code should echo: "Want it Tuesday, $date? Order within $timer(coundown until Monday 4pm)"
Today is Sunday 3pm/6pm: The customer have now time to buy it until tomorrow 4pm to get it Monday so the code should echo: "Want it Tuesday, $date? Order within $timer(coundown until Monday 4pm)"
$time = new DateTime('today 4 PM');
$now = new DateTime('now');
// check if current time is past 6 PM
if ($now > $time) {
$time = new DateTime('tomorrow 4 PM');
}
$diff = $time->diff($now);
$dw = date( "w");
if ($dw == 6 || $dw == 0) {
$datetime = new DateTime('today');
if ($dw == 6) {
$datetime->modify('+3 day');
} else {
$datetime->modify('+2 day');
}
echo "Contact us again at: " . $datetime->format('Y-m-d');
} else {
//echo "<span>Today is:</span> " . date('<b>l jS \of F Y</b>')."<br/>";
$datetime = new DateTime('today');
$datetime->modify('+1 day');
}
echo "Delivery: ". $datetime->format('<b>l, d F</b>') . ": <span style ='color:#198504'>Order in: </span> ";
echo $diff->format("<span style ='color:#198504'>%h hours und %i Minutes.</span>");
}
What can I change that the script works like I want