I have this code:
var_dump(strtotime('2020-10-25 02:05') > strtotime('-5 minutes'));
It was executed when my system clock was 2020-10-25 02:04. It answered false, even though that timestamp obviously was "greater than" ("younger") than "the current time minus 5 minutes" at the time it was executed. (It was only 1 minute ago.)
However, with zero code changes, it has answered true for that kind of query until a specific hour, which happens with six months apart.
You see, it's switched over to "winter time" where I live now. This means that at some point, I assume midnight UTC, time either goes back or forward one hour.
Since my timezone is two hours after the UTC, that "magic hour" is 01:00-02:00, or 02:00-03:00. Those details aren't the important part.
Just to make it clear: the same exact code stopped answering false, instead answering true, once it had "switched over" to winter time. It was returning the wrong answer for an entire hour.
I have one hour every six months to try to debug this, because there is no sane way (that I know of) to change the perceived system time to PHP, for an individual script, without changing the entire computer's time, which would mess all kinds of things up if I did that.
What exactly am I missing? It's obvious that it has to do with the winter/summer time nonsense, but why? Yes, strtotime converts a time to a Unix epoch, which has no concept of timezones, but it does count a fixed number of seconds since a specific historic moment, so why does it matter? My timestamps come from the same machine, the same PHP script, and it doesn't just happen briefly when it just switches over, but for (at least) an entire hour!
You have no idea how much hair I've been pulling away from my hair for years until I just now, before asking this, realized what causes this to happen. I thought I had gone insane when no changes in my code caused different answers from PHP. But I still don't understand why.
Can you explain why it would be so confused when both timestamps compared use the same timezone anyway?