Question

I have an NSDate object, and I need to check if it has already passed. If so, turn that date into the date of tomorrow, but I can't lose information like TimeZone in the process.

Could you plz help me?

Was it helpful?

Solution

NSDate has no timezone info. It's just a thin layer over the number of seconds elapsed since its epoch. You can use a calendar and a timezone to turn it into an NSDateComponents, fiddle with the date there, and then format that into a new NSDate.

OTHER TIPS

NSDate *date = ...;
if ([[NSDate date] timeIntervalSinceDate:date] > 0) {
    date = [date dateByAddingTimeInterval:24*60*60];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top