Hello i have a special timezone like Europe/Berlin and i would like to add 90 days to the current date. After that i detect the last day of month.
My Dates in the database are saved in UTC. That is why i must change the timezone at the end.
My Problem is, that the Timezone change subtract 2 hours from the time between Europe/Berlin and UTC. When i don't modify the datetime object before i change it to UTC then it will subtract just 1 hour. Can anybody tell me what the problem is or the correct solution?
//$timezone = 'Europe/Berlin';
private function getMaxTillDate($timezone)
{
$threemonth = new \DateTime('now', new \DateTimeZone($timezone) );
$threemonth->setTime(23, 59, 59);
$threemonth->add(new \DateInterval('P0Y90DT0H0M'));
$maxday = $threemonth->format('t');
$threemonth->setDate($threemonth->format('Y'), $threemonth->format('m'), $maxday);
$threemonth->setTimezone(new \DateTimeZone('UTC'));
return $threemonth;
}
Thank you very much