如何在sqlite中添加dateTime的时间?
我有一张表,表中有一个日期 creationDate 。它存储这样的时间戳
I have a table and in the table there is a date creationDate. which stores the timestamp like this
2013-12-23 10:07:42
2013-12-23 10:14:11
其实我正在使用mysql2sqlite.sh脚本将数据库从mysql转换为sqlite 。而在转换数据库时,它从creationDate列减少了时间5:30。这可能是一些 GMT 问题。
所以现在我想更新时间戳,并在creationDate列中的每个条目添加5小时30分钟。
我搜索了很多,但是我没有找到解。
那么我如何在sqlite中执行?
Actually I was using the mysql2sqlite.sh script to convert the database from mysql to sqlite. and while converting database it reduced the time 5:30 from the creationDate column. It might be some GMT problem.
So now I want to update the timestamp and add 5 hours 30 minutes to each entry in the creationDate column.
I searched about it a lot but i didnt find the solution.
So how can i do it in sqlite ?
你可以使用 sqlite date函数,用于简单的数学运算,如下所示:
You can use the sqlite date functions for simple math like this:
UPDATE tablename SET creationDate=DATETIME(creationDate, '+330 minutes');
尽管通常在显示数据库数据时保持数据库的数据并以格式显示本地时区。
Though usually it makes more sense to keep the database data in UTC and format to local timezone when displaying it.