I'm a bit stumped on this particular problem.
The Code Below seems to work when it feels like it. Today (tuesday) at 4pm i expected the date to change from Wednesday 02 to Thursday 03, but it went blank.
Basically we offer a Nextday delivery if the customer orders before 4pm, after 4 it will go onto the following day.
Any ideas why some days work and some dont?
Any input would be appreciated!
Code: Select all
<?php
$day_today = date("l"); // Today's Day
$time_today = date("G"); // Today's Time
$tomorrow = date( "jS", strtotime("+1 day") ); // Today's Day + 1
$tomorrow2 = date( "jS", strtotime("+2 day") ); // Today's Day + 2
$tomorrow3 = date( "jS", strtotime("+3 day") ); // Today's Day + 3
$tomorrow4 = date( "jS", strtotime("+4 day") ); // Today's Day + 4
$tomorrow5 = date( "jS", strtotime("+5 day") ); // Today's Day + 5
?>
<!-- Displays the Next Available Delivery Date -->
<?php
if ($day_today == "Monday" && $time_today < 16 ) { // If Today's Day is equal to Monday and Before 4pm, Shows Tomorrows Day & Date
echo $day_tomorrow; // Show Tomorrows Day
echo $tomorrow ; // Show Tomorrows Date
} elseif ($day_today == "Monday" && $time_today > 16 ) { // If Today's Day is equal to Monday and after 4pm, Show Day & Date + 1
echo "Wednesday "; // Due to Time being after 4pm, Show The Day after Tomorrow
echo $tomorrow2; // Due to Time being after 4pm, Show The Date after Tomorrow
} elseif ($day_today == "Tuesday" && $time_today < 16 ) { // If Today's Day is equal to Tuesday and Before 4pm, Shows Tomorrows Day & Date
echo "Wednesday "; // Show Tomorrows Day
echo $tomorrow; // Show Tomorrows Date
} elseif ($day_today == "Tuesday" && $time_today > 16 ) { // If Today's Day is equal to Tuesday and after 4pm, Show Day & Date + 1
echo "Thursday "; // Due to Time being after 4pm, Show The Day after Tomorrow
echo $tomorrow2; // Due to Time being after 4pm, Show The Date after Tomorrow
} elseif ($day_today == "Wednesday" && $time_today < 16 ) { // If Today's Day is equal to Wednesday and Before 4pm, Shows Tomorrows Day & Date
echo "Thursday "; // Show Tomorrows Day
echo $tomorrow; // Show Tomorrows Date
} elseif ($day_today == "Wednesday" && $time_today > 16 ) { // If Today's Day is equal to Wednesday and after 4pm, Show Day & Date + 1
echo "Friday "; // Due to Time being after 4pm, Show The Day after Tomorrow
echo $tomorrow2; // Due to Time being after 4pm, Show The Date after Tomorrow
} elseif ($day_today == "Thursday" && $time_today < 16 ) { // If Today's Day is equal to Thursday and Before 4pm, Shows Tomorrows Day & Date
echo "Friday "; // Show Tomorrows Day
echo $tomorrow; // Show Tomorrows Date
} elseif ($day_today == "Thursday" && $time_today > 16 ) { // If Today's Day is equal to Thursday and after 4pm, Show Day & Date + 1
echo "Monday "; // Due to Time being after 4pm, Show The Day after Tomorrow
echo $tomorrow4; // Due to Time being after 4pm, Show The Date after Tomorrow
} elseif ($day_today == "Friday" && $time_today < 16 ) { // Due to non-delivery at the weekends, the next availble day is Monday, (Today's Day + 3)
echo "Monday "; // Due to Day beeing Friday, Show Monday
echo $tomorrow3; // Due to Day beeing Friday, Show the Date + 3
} elseif ($day_today == "Friday" && $time_today > 16 ) { // Due to non-delivery at the weekends & The time being after 4pm, the next availble day is Tuesday, (Today's Day + 4)
echo "Tuesday "; // Due to Day beeing Friday & after 4pm, Show Tuesday
echo $tomorrow4; // Due to Day beeing Friday & after 4pm, Show the Date + 4
} elseif ($day_today == "Saturday") { // Due to non-delivery at the weekends, the next availble day is Tuesday, (Today's Day + 3)
echo "Tuesday "; // Due to Day beeing Saturday, Show Tuesday
echo $tomorrow3; // Due to Day beeing Saturday, Show the Date + 3 (to show Tuesday)
} elseif ($day_today == "Sunday") { // Due to non-delivery at the weekends, the next availble day is Tuesday, (Today's Day + 2)
echo "Tuesday "; // Due to the Day beeing Sunday, Show Tuesday
echo $tomorrow2; // Due to the Day beeing Sunday, Show the Date + 2 (to show Tuesday)
}
?>