Reputation: 6465
In my app I want to show timings of different countries like Japan UK USA France how can I do that?
Upvotes: 0
Views: 1053
Reputation: 15115
Get the current date by,
NSDate *today=[NSDate date];
Then using NSTimezone
get the timings for different countries.
Sample code
NSDate* sourceDate = [NSDate date];
NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"JST"];
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];
NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
NSDate* destinationDate = [[[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate] autorelease];
Upvotes: 1
Reputation: 16553
Here is a sample code from apple related to time zones
http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html
Upvotes: 1