I\'m currently developing an online subscription application. I\'m having some challenges on the part where the user will select the Number of Days to subscribe and then the
I have developed a new function today that can help people who have this type of problem. Depends how the startdate is sent, but assuming you are using Y-m-d you can use DateTime
getTimestamp();
// loop for X days
for( $i = 0; $i < ( $orderDays - 1 ); $i++ ) {
// get what day it is next day
$nextDay = date('w', strtotime('+1day', $date_timestamp) );
// if it's Sunday or Saturday get $i-1
if( $nextDay == 0 || ( $nextDay == 6 && $saturday_off ) ) { $i--; }
// modify timestamp, add 1 day
$date_timestamp = strtotime('+1day', $date_timestamp);
}
$formatted_date->setTimestamp($date_timestamp);
return $formatted_date->format( 'Y-m-d' );
}
$orderEndDate = getOrderEndDate( '2020-06-17', 'meal_monthly_6' ); ?>