I'm trying to implement this algorithm for generating 3 possible delivery dates for an order on my store, which the user can choose during checkout: The store delivers Monday to Friday. The server must return an array with 3 possible delivery dates according to these rules: 2) the store delivers from Monday to Friday
- if the order is made by 10 am then this can also be delivered on the same day (if from Monday to Friday)
I have tried several paths and this is what I have come up to now. Could anyone help me complete this algorithm?
public function test(){
$today = date();
$todayCode = date('N');
$possibleShippingDates = [];
while(count($possibleShippingDates)<3) {
if($todayCode <6) {
array_push($possibleShippingDates, $today);
//go to next day?
// $today = today + 1 day
// $todayCode = date('N', $today)
}
}
return $possibleShippingDates;
}