How to convert Unix epoch time in SQLite
1319017136629
is a value in milliseconds
, which is not UNIX
epoch time;therefore it has to be divided by 1000
and rounded to integer seconds
; only then DATE()
and DATETIME()
will convert.
SELECT DATETIME(ROUND(dateColumn / 1000), 'unixepoch') AS isodate FROM tableName
Converting database values to localtime
is unfortunate; conversion on output is less problematic.
The Y2038 problem might already be worth a consideration.