How can I get the real time in the iPhone, and not the time set by the user in the settings?

I need to make sure that my application receives the correct time, and not the time specified by the user in the settings.

So, for example, as soon as the user starts the application, I want to get a timestamp. The user will see elapsed time on a timer on a screen updated every second. When the user exits the application and after a while restarts the application, the timer will simply get the current time and compare it with the original time stamp that he saved. Thus, basically, just like the stopwatch in Clock.App on the iPhone.

Now the problem with clock.app is that if the user goes and advances the time in the settings by one hour, this will affect the timer. Obviously, I do not want this because in my application it will be cheating.

I need to get a more reliable source of time for comparison.

I could get time from the internet. But the problem is that I need an Internet connection, so it only works if there is an Internet connection. My application should work offline.

Are there any internal clocks that I can access?

Is there a way to check if the user has changed the date time in the settings?

Any other ideas?

thanks

+5
source share
4

NIST :

UDP UDP UDP- 13. , ASCII ( ).

NIST : JJJJJ YR-MO-DA HH: MM: SS TT L H msADV UTC (NIST) OTM

http://tf.nist.gov/service/its.htm

http://tf.nist.gov/tf-cgi/servers.cgi

+1

, , mach, iphone.

. , .

, iphone, mach, , , . : iPhone DateTime , , .

, iphone

: iphone, , .

+1

:

, GPS:

#import <CoreLocation/CoreLocation.h>

CLLocation* gps = [[CLLocation alloc]
                       initWithLatitude:(CLLocationDegrees) 0.0
                       longitude:(CLLocationDegrees) 0.0];
NSDate* now = gps.timestamp;

, , .

iPhone 4 (iOS 6.1), . , , , , . .

, ( ), , ( off Set Automatically), Set Automatically on, () . . , - , , . ?

0

, google.com:

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
                                initWithURL:[NSURL URLWithString:@"http://google.com"]];

[request setHTTPMethod:@"GET"];

NSHTTPURLResponse *httpResponse = nil;
[NSURLConnection sendSynchronousRequest:request returningResponse:&httpResponse error:nil];
NSString *dateString = [[httpResponse allHeaderFields] objectForKey:@"Date"];
NSDate *currentDate = [NSDate dateWithNaturalLanguageString:dateString locale:NSLocale.currentLocale];
0
source

All Articles