How to change SQLITE database timestamp to local timestamp

I am inserting an entry into the sqlite database by the current_timestamp date. The idea ist, not to set the time manually. Now the fact is that my date in the database is 5.30 hours after insertion. Any ideas how to get around or fix this?

+6
source share
2 answers

use:

CREATE TABLE table ( ... , yourColumnName DATETIME DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'LOCALTIME')) , ... ); 
+17
source

The timestamp returned by current_timestamp is in UTC.

To convert it to the local current time zone, use the datetime function:

 INSERT INTO MyTable(MyColumn) VALUES(datetime(CURRENT_TIMESTAMP, 'localtime')) 
+9
source

All Articles