SQLite Current Timestamp with Milliseconds?

后端 未结 4 1800
感动是毒
感动是毒 2020-12-29 04:57

I am storing a timestamp field in a SQLite3 column as TIMESTAMP DATETIME DEFAULT CURRENT_TIMESTAMP and I was wondering if there was any way for it to include mi

4条回答
  •  执笔经年
    2020-12-29 05:20

    The following method doesn't require any multiplies or divides and should always produce the correct result, as multiple calls to get 'now' in a single query should always return the same result:

    SELECT strftime('%s','now') || substr(strftime('%f','now'),4);
    

    The generates the number of seconds and concatenates it to the milliseconds part from the current second+millisecond.

提交回复
热议问题