Reputation: 331
18.11.2009 10:32:00
I want the value in between the above tag(created) to be inserted into the sqlite db for which i have taken a column of type timestamp.... how can i store this value in that column?? please advise...
Upvotes: 0
Views: 3613
Reputation: 3960
Well, it depends in which format you want to save it in your database.
If you want to save it in the string form, then save it directly by making an object. But, use the datatype of string type.
Another option is to save it using the date datatype, seeing as sqlite doesn't have a dedicated date/time datatype.
Use a formatter to set the date format:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-MM-YYYY HH:MM:SS"];
Then make Date object, and save it.
Upvotes: 2
Reputation: 12787
Make object for date
then use this
[date timeIntervalSinceDate:objDate];
this give time interval beetween the date and objDate. two dates(date and objDate) for finding timeInterval.
Save this by convert it into string.
Upvotes: 0
Reputation: 30651
Two options here (if you want sorting, which I assume you do):
2009.11.18 10:32:00
1261153920
It is then simple to pull it out using date and time functions.
Note that SQLite does not have a date/time data type.
Upvotes: 0
Reputation: 7486
You should replace dots by hyphens and place months, days and year parts in correct order. According to sqlite docs these are the date and time accepted formats:
Upvotes: 1