Today I fixed a bug in our application that was interesting to figure out. Without a ton of detail, the gist is that if you convert a datetime to unix timestamp in MySQL:
mysql> select UNIX_TIMESTAMP('2006-10-28 04:00:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2006-10-28 04:00:00') |
+---------------------------------------+
| 1162022400 |
+---------------------------------------+
1 row in set (0.00 sec)
And then add 24 hours to it:
mysql> select 1162022400 + (60*60*24); +-------------------------+ | 1162022400 + (60*60*24) | +-------------------------+ | 1162108800 | +-------------------------+ 1 row in set (0.00 sec)
And then convert it back to a datetime it magically loses an hour:
mysql> select FROM_UNIXTIME('1162108800');
+-----------------------------+
| FROM_UNIXTIME('1162108800') |
+-----------------------------+
| 2006-10-29 03:00:00 …[Read more]