Jaxel
Well-known member
I have 3 values:
I then take these 3 values and run it through a script:
As you can see, I am setting the current time to be the beginning of Week 52 in 2019.
I am then trying to get information about the next week.
This script has worked in almost every instance I have found...
Hopever, in Week 52 in 2019, instead of returning the next week as Week 1 in 2020, it returns the next week as Week 1 in 2019... which sends me backwards in time.
How do I fix this? This seems to happen in every year where there are 53 weeks in the year.
Code:
$timezone = new \DateTimeZone('America/New York');
$year = 2019
$week = 52
I then take these 3 values and run it through a script:
Code:
$nowTime = new \DateTime('now', $timezone);
$currTime = clone $nowTime;
$currTime->setISODate($year, $week, 1);
$currTime->setTime(0,0,0);
As you can see, I am setting the current time to be the beginning of Week 52 in 2019.
I am then trying to get information about the next week.
Code:
$nextTime = clone $currTime;
$nextTime->modify('+1 week');
$nextWeek = [
'year' => $nextTime->format('Y'),
'week' => $nextTime->format('W'),
];
This script has worked in almost every instance I have found...
Hopever, in Week 52 in 2019, instead of returning the next week as Week 1 in 2020, it returns the next week as Week 1 in 2019... which sends me backwards in time.
How do I fix this? This seems to happen in every year where there are 53 weeks in the year.