dimanche 8 mars 2015

SqlLite, iOS, unix epoch conversion

I have two rows in my database, with timestamps for Saturday February 7th, and Friday March 6th.


I am running this query:


select strftime('%w', datetime(CreationDate / 1000, 'unixepoch')), datetime(CreationDate / 1000, 'unixepoch'), CreationDate from mytable


Output is: "6" "2015-03-07 02:17:02" "1425694622000" "6" "2015-02-07 05:00:00" "1423285200000"


So clearly something is wrong, it's saying both these timestamps are on Saturday. I assume the problem is that i'm dividing my timestamp by 1000 before casting it to the unix epoch and datetime doesn't like this?


What would be a recommendation to get back the correct date in datetime? I really need to store things in milliseconds not some other time.


Thanks so much for your help!


Aucun commentaire:

Enregistrer un commentaire