views:

715

answers:

3

i have a date converted to double value and saved in database.now i want to compare if cureentdate > myDataBaseDate+8 hours. means i want to get 8 hours more added in my database date. i'm converting date into double values.so how do i get 8 hours later time from my database saved date. how do i compare if(currentDateTime>DateFromdatabaseValue+DateByAdding8HoursInDataBase)

A: 

You can simply add 8 * 3600 to your database value (assuming that your converted double value represents seconds).

Pascal
+6  A: 

I'm not entirely sure what you are trying to do, but you can create an NSDate object by adding time in seconds on to another NSDate using:

- (id)dateByAddingTimeInterval:(NSTimeInterval)seconds

eg. to add 8 hours:

NSDate *mydate = [NSDate date];
NSTimeInterval secondsInEightHours = 8 * 60 * 60;
NSDate dateEightHoursAhead = [mydate dateByAddingTimeInterval:secondsInEightHours];
Tom
Thanks a lot. I needed to know that two :)
rdesign
A: 

dateByAddingTimeInterval method does not exist. you need to use [mydate addTimeInterval:secondsInEightHours];

Vijay Shankar