如何在sqlite中获取当前时间戳?当前时间、当前日期、当前时间戳都返回格式化日期,而不是长日期。
sqlite> insert into events (timestamp) values (current_timestamp); sqlite> insert into events (timestamp) values (current_date); sqlite> insert into events (timestamp) values (current_time); sqlite> select * from events; 1|2010-09-11 23:18:38 2|2010-09-11 3|23:18:51
我想要什么:
4|23234232
这个 docs 提及此方法:
SELECT strftime('%s', 'now'); 1284248196
这一部分包括小数部分:
SELECT (julianday('now') - 2440587.5) * 86400.0; 1284248196.65098
两个代表 Unix Time ,1970年1月1日以来经过的秒数。