I've been reading my way through the PHP documentation, but I've hit a wall. New to PHP here.
The idea of this script is pretty straightforward: Before 10 a.m. on Mon, Tue & Wed - order ships same day. After 10 a.m. on Wed - order ships Monday. All day Thursday, Friday, Saturday and Sunday - order ships Monday
I am trying to check the day of the week and time of day to tell the user when their order will ship. I found that when $current_time = date("H"); for the whole 10:00 a.m. hour I get an error showing all three options:
- your order will ship today.
- your order will ship tomorrow.
- your order will ship monday.
I'm sure that this is because of my poorly written if statement.
Then I moved on to using date("H:i");, but to no avail. I know that I'm probably doing something wrong with writing something like this:
else if ($d < 4 && $current_time >= 10:00) {
Source:
<?
$current_time = date("H:i");
$d = date("N");
if ($d > 3) {
echo('<p>your order will ship monday</p>');
}
else
if ($d < 4 && $current_time >= 10:00) {
if ($d = 1 && $current_time <= 10:00 || $d = 2 && $current_time <= 10:00) {
echo('<p>your order will ship today.</p>');
}
if ($d = 1 && $current_time >= 10:01 || $d = 2 && $current_time >= 10:01) {
echo('<p>your order will ship tomorrow.</p>');
}
if ($d = 3 && $current_time <= 10:00) {
echo('<p>your order will ship monday.</p>');
}
}
?>
I'm sure this could be slimmed down quite a bit. Any help is greatly appreciated.