How do I save and retrieve the date + time in the sqlite3 database?

advertisements

i want to save current date+time into database and also want to retrieve it. i know that in objective-C we cannot save date+time directly. i have double as a field into database and currently I'm saving date by converting it into double.

here is the method for converting date into double-

currentDate=[NSDate date];

startDate=(double)[currentDate timeIntervalSince1970];

now how do i retrieve date back from that double value? or is there another way to save dates in iPhone SDK.


NSDate *dateFromDouble(double interval) {
  return [NSDate dateWithTimeIntervalSince1970: interval];
}