I know it's a repeating a question , but i didn't get solution from those answer's . please can anybody tell me , How do I get GMT in ios , if the device time is wrong also .
Thanks in advance
Try the below:
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm";
NSTimeZone *gmtZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
[dateFormatter setTimeZone:gmtZone];
NSString *timeStamp = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"%@",timeStamp);
You must rely on an external server to achieve this. There is no built in method other than the ones for recovering the local phones time.
Here is a github project where they try to do exactly this for iOS : https://github.com/jbenet/ios-ntp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.