Take the 2-minute tour ×

I noticed that if I set my device time manually, and turn off the automatic time sync on my iOS device, [NSDate date] returns the date and time assuming the device time is correct--which it may not be.

Since the docs mention that NSDate has some sort of sync with NTP, I am wondering if there is any built-in way to get the accurate date and time instead of having to assume the device date and time is correct.

share|improve this question
I find one valuable check is to simply make sure that the phone's time value is greater than the date you shipped your app (or some such), so that you eliminate the case where the date has reset to Jan 1, 1970 or whatever. In that case throw up a message "Set your clock, you idiot!" (Or words to that effect.) –  Hot Licks Feb 19 '13 at 18:13
@HotLicks this will in no way ensure that the time is correct as the OP is asking. –  twaldron Feb 19 '13 at 18:45
True, but it catches, especially, a lot of iPad Touches with the clock set totally wrong. –  Hot Licks Feb 19 '13 at 19:04
@HotLicks I do see value in having this check, although this whole discussion and answers make me want to re-engineer the whole thing to not need accurate times as there seems to be no solution without 3rd-party code. –  Anton Feb 19 '13 at 19:42
@HotLicks fair enough :) –  twaldron Feb 19 '13 at 19:42
add comment

2 Answers

up vote 1 down vote accepted

Perhaps https://github.com/jbenet/ios-ntp can help you? It's a library that can fetch the date and time from a time server.

share|improve this answer
It seems this is the easiest way to do it, out of all the available options. –  Anton Feb 25 '13 at 15:46
What other options could there be to solve this issue? –  AppsDev May 6 '13 at 14:07
add comment

See this api to fetch current date and Time then compare.

share|improve this answer
add comment

Your Answer


