Reputation: 1536
I am working on a project which involved in converting current time on iPhone to target destination's time. For example, the application needs to convert current time (08:00) to Germany's local time.
I have information about timezone (like UTC +1) and tried to search about how to use NSTimeZone to convert the NSDate value, but it looks like I have to ask your help here.
Could you give me any suggestion? or point me out for some solution?
Upvotes: 1
Views: 3253
Reputation: 2262
This guide on working with time zone differences from Apple might be a useful guide to follow.
Upvotes: 0
Reputation: 85522
The simplest thing is probably to use -[NSTimeZone secondsFromGMTForDate:] for each time zone, and then figure out the delta between the two:
NSInteger offset1 = [timezone1 secondsFromGMTForDate: date];
NSInteger offset2 = [timezone2 secondsFromGMTForDate: date];
return [date addTimeInterval: (offset1 - offset2);
Upvotes: 2