我的 Sqlite 数据库中有一个 Date 列。当我将一些 NSDate
值放入其中,并通过图形工具打开 Sqlite 文件时。我得到一些值,例如 530963469.705571。对应的日期是今天或昨天左右。
这显然不是 Unix 纪元日期戳值。 这个值到底是什么意思?
我需要更改此值才能调试我的应用。
最佳答案
NSDate objects encapsulate a single point in time, independent of any particular calendrical system or time zone. Date objects are immutable, representing an invariant time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001).
由于 sqlite 不直接支持 NSDate
,因此日期作为基础值持久化。 530963469.705571 表示 2001 年 1 月 1 日 00:00:00 UTC 与您创建 NSDate
您可以使用 NSDate
初始化程序 init(timeIntervalSinceReferenceDate:)
从时间间隔值创建一个 NSDate
。
关于iOS Sqlite NSDate 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47008663/