I have some pages that require a date to be set in the future (either 2 or 5 days as set by a variable). This date needs to be only counting Monday - Friday, excluding weekends.
What I have so far ($tts is the variable of 2 or 5 depending on page);
$Today = date('N:m:y');
$NewDate = date('l \t\h\e jS \o\f F',strtotime($Today) + (24*3600*$tts));
$businessDays = [1, 2, 3, 4, 5];
echo $NewDate;
This works without excluding weekend days. I have tried to use the $businessDays but I'm unsure of how I can use this to count what days are between $Today and $NewDate
Try:
$plusFive = strtotime( '+5 weekday' );
$plusFive = date( 'Y-m-d', $plusFive );
strtotime also takes a second parameter which could be the base for the +5.
Try this code.
It should pick a weekday $tts days ahead.
$Today = date('N:m:y');
$NewDate = date('l \t\h\e jS \o\f F',strtotime($Today . '+' . $tts .' weekdays'));
echo $NewDate;
https://3v4l.org/4SX0m
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With