The scenario is I want to keep the device time correct if the device time is incorrect then I want to change it to the correct time0.
In order to do this I have 3 challenges:
get device UTC time.
get correct UTC time from the internet
if the time is not correct then make it correct
I am able to complete 1 challenge by using the code given below:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; [dateFormatter setTimeZone:timeZone]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSString *dateString = [dateFormatter stringFromDate: [NSDate date]];
how ever I need your help to complete other two challenges. Please help