Trying to figure out a way of achieving the following scenario:-
The user creates an initial time period e.g. 01/01/2013 to 01/07/2013 and a renewal period e.g. every 1 month.
I'm working on a function that will:-
- Detect whether the date passed in a function (could be any date) falls a period matching the users requirements.
For example:-
The function may accept the following date 21/02/2019. Based on this I need to detect which renewal period the user is in.
The way I was thinking of achieving this is by:-
- Add one day to the users initial start date to get the newest renewal date.
- Add the renewal period (1 month) to this to get the newest end date.
- Keep doing this until I detect which start and end dates the date falls between based on the users renewal period type e.g. 1 month.
A bit confusing but this kind of sums up what I'm after but isn't working:-
$tmpStartDate=$endDate;
do{
$tmpStartDate=date("Ymd",strtotime($tmpStartDate .'+1 Day'));
$tmpEndDate=date("Ymd",strtotime($tmpStartDate .'+'.$timingUnitVal .' '.$timingUnit));
} while($date<$tmpStartDate&&$date>$tmpEndDate);
$endDate is the end date initially entered by the user.