Sqlite: CURRENT_TIMESTAMP is in GMT, not the timezone of the machine

后端 未结 11 925
小蘑菇
小蘑菇 2020-11-29 16:36

I have a sqlite (v3) table with this column definition:

\"timestamp\" DATETIME DEFAULT CURRENT_TIMESTAMP

The server that this database live

11条回答
  •  无人及你
    2020-11-29 16:47

    You can also just convert the time column to a timestamp by using strftime():

    SELECT strftime('%s', timestamp) as timestamp FROM ... ;
    

    Gives you:

    1454521888

    'timestamp' table column can be a text field even, using the current_timestamp as DEFAULT.

    Without strftime:

    SELECT timestamp FROM ... ;
    

    Gives you:

    2016-02-03 17:51:28

提交回复
热议问题