4

I just read in the docs that:

Cocoa implements time according to the Network Time Protocol (NTP) standard, which is based on Coordinated Universal Time.

I am correct to assume that for OSX is syncing with the internet, correct?

What about iOS devices? Are the same NSObjects (NSDate, NSCalendar, etc...) also syncing with the internet, or are they getting time from the iPhone's carrier (e.g., AT&T, Verizon, etc...)? Does Cocoa-Touch work in the same way as Cocoa with respect to getting and syncing time?

If it doesn't, and instead, gets time from the carrier, what would be the way one would grab the time from the internet for an iOS application? I don't need sample code - I only need to be pointed in the right direction.

Thanks!

ArtSabintsev
  • 5,170
  • 10
  • 41
  • 71

1 Answers1

2

iOS is getting time from different sources, one of them is the NTP. Ideally the time is updating from the GPS - which is the most accurate time that you can get (it's an atomic clock basically), or from the carrier (through the NITZ). Otherwise, the device falls on the NTP. Lastly, when you plug in your device to iTunes, your time is being updated as well. So Cocoa touch differs in that it has both the GPS and the carriers that Cocoa doesnt have.

TommyG
  • 4,145
  • 10
  • 42
  • 66
  • Is there a way to programmatically grab the time from one or two of these sources, say GPS and NTP? – ArtSabintsev Sep 13 '11 at 19:03
  • No. thats being managed in the iOS level, same as how core location is calculating your location - GPS, cell, Wifi, etc. They just give you the best they can. – TommyG Sep 13 '11 at 19:23
  • iOS time is very inaccurate. Off by several seconds between different devices. Even with automatic settings. – openfrog Sep 02 '13 at 11:57
  • How to get that time, in NSDate i always get carrier date! – IgniteCoders Nov 05 '13 at 16:05