Strange behaviour of epoch() when converting from Unix time

Marc Ballarin marc.ballarin at 1und1.de
Tue Apr 12 11:46:43 CEST 2016


Hi,

I am observing a surprising behaviour of the epoch function:

The following works as expected:
SELECT epoch(now()) AS "NOW", epoch(now() - INTERVAL '5' MINUTE) AS "5
MIN AGO";
+------------+------------+
| NOW        | 5 MIN AGO  |
+============+============+
| 1460453860 | 1460453560 |
+------------+------------+

The inverse does not:
SELECT epoch(1460453860) AS "NOW", epoch(1460453860-300) AS "300 SECONDS
AGO";
+----------------------------+----------------------------+
| NOW                        | 300 SECONDS AGO            |
+============================+============================+
| 2016-04-12 09:37:40.000000 | 1970-01-17 21:40:53.560000 |
+----------------------------+----------------------------+

The "now" part is fine, the "300 seconds ago" part is obviously not what
I expect.

Am I missing something or is this a bug?

Regards,
Marc


More information about the users-list mailing list