SQLite和插入UTC格式的当前日期 [英] SQLite and inserting the current date in UTC format

查看:131
本文介绍了SQLite和插入UTC格式的当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用SQL语句中的sqllite数据库中插入UTC当前日期。我找到了现在功能,但是是什么格式?这将是在移动设备上,以便每个人都会有不同的区域,但是,我需要一个标准的时间格式,因为该设备能在我的服务器的日期进行比较。

How do I use an SQL statement 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.

此外,有没有一种方法能够进行自动更新'修改'字段时,行中的数据被更改一样,你可以在MySQL的?

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('现在')返回当前UTC日期时间。请参见日期和时间函数的。您可以使用DATETIME DEFAULT CURRENT_TIMESTAMP与列声明。

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

格式11,字符串'现在',是
  转换成当前的日期和
  从xCurrentTime获得的时间
  该sqlite3_vfs的方法在对象
  使用。协调世界时(UTC)
  使用

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.

这篇关于SQLite和插入UTC格式的当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆