steveluoxin
steveluoxin

Reputation: 436

iOS Sqlite NSDate value

I have a Date column in my Sqlite database. When I put some NSDate value in it, and open the Sqlite file through graphical tools. I get some value like 530963469.705571. The corresponding date is around today or yesterday.

It's clearly not Unix epoch datestamp value. What exactly does this value mean?

I need to change this value in order to debug my app.

Upvotes: 0

Views: 108

Answers (1)

Paulw11
Paulw11

Reputation: 114783

From the documentation

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).

Since sqlite does not support NSDate directly, the date is persisted as the underlying value. 530963469.705571 represents the number of seconds between 00:00:00 UTC on 1 January 2001 and the time when you created the NSDate

You can use the NSDate initialiser init(timeIntervalSinceReferenceDate:) to create an NSDate from the time interval value.

Upvotes: 2

Related Questions