开发者

SQLite and inserting the current date in UTC format

开发者 https://www.devze.com 2023-01-26 12:28 出处:网络
How do I use an SQL stateme开发者_高级运维nt on an sqllite database to insert the current date in UTC.I found the NOW function but what format is that in?This will be on mobile devices so everyone wil

How do I use an SQL stateme开发者_高级运维nt on an sqllite database to insert the current date in UTC. I found the NOW function but what format is that in? This will be on mobile devices so everyone will have a different locale, however, I need a standard time format because the device will compare the dates with my server.

Also, is there a way to automatically update a 'modified' field when the data in the row is changed like you can in MySQL?


SELECT DATETIME('now') returns the current UTC datetime. See Date And Time Functions. You can use DATETIME DEFAULT CURRENT_TIMESTAMP with column declaration.

Format 11, the string 'now', is converted into the current date and time as obtained from the xCurrentTime method of the sqlite3_vfs object in use. Universal Coordinated Time (UTC) is used

For the 'modified' field you can use a trigger.


You don't specify what you use to develop your application on. I prefer using QDate::toJulianDay and QDate::fromJulianDay in Qt to store dates in an SQLite database as an integer if I only need to store the date.

0

精彩评论

暂无评论...
验证码 换一张
取 消