how to get UTC date time from internet in order to check if the device time is correct or not

| | August 4, 2015

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:

1 challenge:
get device UTC time.

2 challenge:
get correct UTC time from the internet

3 challenge:
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

Leave a Reply