I have a page that need to compare too date.
For those who don’t know it, in Europe the last sunday of march we add 1 hour to the current time so we are in UTC+2h) , and the last sunday of october, we remove the one added in march (so we are in utc+1).
now here is my concern :
I have created a FrozzenTime with the method now().
First, I try
$firstDate = FrozenTime::now('Europe/Paris');
that give :
'time' => '2023-03-28 19:27:11.278474+02:00' 'timezone' => 'Europe/Paris'
I have also try to do something like this too :
$seconddate = FrozenTime::now('UTC')->modify("+2 hours");
added two hours because it is summer time, So I do GMT+1 + 1 hour for the change summer/winter time gives :
'time' => '2023-03-28 19:27:11.278478+00:00' 'timezone' => 'UTC'
I try to compare those two date with this one:
let’s call this $now :
'time' => '2023-03-28 19:35:00.000000+00:00' 'timezone' => 'UTC'
debug($now->diffForHumans($firstDate));//gives '1 hour after' debug($now->diffForHumans($secondDate));//gives '8 minutes before'
the second is the correct answer.
I can use it the second way, because it gives the correct answer, but the problem is that I have to manage manually the winter/summer time and add +1 hour when it is winter time and +2 hours when it is summer time, I can code it easily but would like to do it the right way without reinventing the wheel
I am sure I miss something and I don’t manage that the correct way,
any help is appreciate