如何在SQLite中添加8小时的日期时间而不更新它?就像写入我的数据库时的时间戳一样
这是我的dump.sql
CREATE TABLE IF NOT EXISTS feed (
feed_id INTEGER PRIMARY KEY AUTOINCREMENT,
feed TEXT,
user_id_fk INTEGER,
created DATETIME DEFAULT CURRENT_TIMESTAMP
);
我想添加8小时,因为如果我使用timeago
插件,它会显示8hrs ago
,即使我刚添加了它
这就是我获取数据的方式
getAllFeeds(user_id_fk) {
let data = [user_id_fk]
return this.database.executeSql("SELECT * FROM feed WHERE (user_id_fk) = (?) ORDER BY feed_id DESC", data).then((data) => {
let feeds = [];
if (data.rows.length > 0) {
for (var i = 0; i < data.rows.length; i++) {
feeds.push({ feed_id: data.rows.item(i).feed_id, feed: data.rows.item(i).feed, user_id_fk: data.rows.item(i).user_id_fk, created: data.rows.item(i).created });
}
}
return feeds;
}, err => {
console.log('Error: ', err);
return [];
});
}
答案 0 :(得分:0)
试试这个
SELECT DATETIME(created, '+8 hours') as `add8hours` FROM feed WHERE (user_id_fk) = (?) ORDER BY feed_id DESC;