Sqlite中如何获取当前时间戳? current_time、current_date、current_timestamp 都返回格式化日期,而不是长日期。
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 日以来经过的秒数。
关于sqlite - sqlite 中的 Unix 时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3693076/