I am doing some comparisons between datetime in MySQL with PHP. In MySQL time is incremented by 1 between Nov 2, 2014 and March 8, 2015 due to daylight saving time.
So far I have if statements that check whether I need to subtract 1 hour before comparing two datetimes or not. It is only good for 2014/2015 and I wonder if there is way to do the same for previous years without hardcoding the exact dates as I did above?
The comparison must be made on the fly in PHP, cant modify schema.
HERE IS SOME DATA:
2014-10-15 18:00:00
2014-10-22 18:00:00
2014-10-29 18:00:00
2014-11-05 19:00:00
2014-11-12 19:00:00
2014-11-19 19:00:00
So, all of these guys are suppose to have the same time and to compare them I need to modify on the fly those that are after Nov 2.
CLARIFICATION: All I need is to take 2014-10-29 18:00:00 and 2014-11-05 19:00:00 (thats how they are in MYSQL) and tell whether this dates have THE SAME TIME ONLY. Due to DST, the server incremented the second entry to 19:00:00 hrs and I need to handle that in PHP with whatever built in stuff it has.
E.g.
$d = new DateTime('2014-10-29 18:00:00', new DateTimezone('America/New_York'));
$dd = new DateTime('2014-11-05 19:00:00', new DateTimezone('America/New_York'));
echo $d->diff($dd)->format('%h:%m:%s'); <<<<Should give 0 hr difference in my case