I am using the following lines to calculate a 4-week interval in PHP.
This uses a fixed date ($calStart
) as basis for the calculation and ends the interval with the last day of the selected year ($rangeEnd
/ $selYear
) which works well so far.
Example: If the selected year is 2015 than the first date in my range here should be 2015-01-16 as the first interval date in the selected year.
Can someone here tell me how I can set this so that $rangeDays
only starts with the first interval date in the selected year instead of returning all intervals since the $calStart
date (which is what it does at the moment) ?
$calStart = new DateTime('2014-01-17');
$interval = DateInterval::createFromDateString('4 weeks');
$rangeEnd = new DateTime($selYear . '-12-31');
$rangeDays = new DatePeriod($calStart, $interval, $rangeEnd);
Many thanks for any help with this, Tim.