Is it possible to get the atomic clock timestamp from the iphone GPS?

This works to get the GPS time:

#import <CoreLocation/CoreLocation.h>

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

It doesn’t seem to be tamper-proof though.

I tried this code on an iPhone 4 in airplane mode (iOS 6.1), and even then it gives a time all right. But unfortunately this time seems to change with the system clock. Ugh.

Funny thing that I found (still in airplane mode) is that if you tamper with the system clock (after turning to off Time & Date’s Set Automatically), and then turn Set Automatically back to on, the machine restores the real (original) time without a hitch. this works even after cycling the phone’s power. So it seems that there is something like a tamper-proof time the device maintains internally. But how to access this?

P.S. A discussion of this from 2010. The author of the penultimate comment tried this in a fallout shelter: so it’s clear the phone is not getting the pristine time from any external source.

Addendum, July 2013

Found a few more posts (here, here and here) about another kind of time measure: system kernel boot time. It’s accessed through a call something like this: sysctlbyname("kern.boottime", &boottime, &size, NULL, 0);. Unfortunately it too changes with the user-adjusted data and time, even without reboot. Another function gettimeofday() is similarly dependent on user-defined time.

Leave a Comment