After some struggling with how the Daylight Saving Time change affected my code, I realized that one shouldn't mess with the time zone offsets on his own (i.e. Add or Subtract hours manually from the UTC time), because underlying libs already implement it - and probably better (yes, including DST changes, works flawlessly!). Here are the new simple rules I set to myself:
- Absolute time: Store dates only relative to UTC (usually [milli]seconds since Unix epoch or another reference date. The familiar Timestamps are measured as UTC and not as Local Time!
- Absolute-to-Local: When local date matters, convert UTC-to-local (and vice versa) using the already-existing methods:
- PHP: date() and many, many other PHP date functions
- Libc and Perl: localtime() and friends
- MFC: CTime object (Don't trust me too much for Windows tips though)
Bottom line: stick to UTC as much as you can, it's good for you.
Trivia line: Morocco is GMT+0 and has no Daylight Saving Time (so it's identical to UTC). Good for them, eh?