Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Date and Time from Apple Server

Tags:

I'm developing an app that can only be used during a certain time of the day. I can't get the local device time because the user can easily change the device time thereby allowing access to the application for any time of the day.

Is there a way to get the current date and time from an Apple server (or if not,) is there any other way?

like image 258
kraitz Avatar asked Jan 31 '12 06:01

kraitz


People also ask

What is the Apple time server?

Network time servers are the authoritative timekeepers of the internet, ensuring that everyone has the right time. Apple's time server ( time.apple.com ) is the default time server for your Mac, but you can switch to another time server, such as one maintained by your employer or university.

Why is my Mac showing the wrong date and time?

Check Language & Region preferences Choose Apple menu  > System Preferences, then click Language & Region. Make sure that the Region menu is set correctly for your region. Use the ”Time format” checkbox to control whether your Mac displays time in the 24-hour format.


1 Answers

I think that you should be using an Internet time server. They are using a standardized protocol called NTP. The iOS has built-in support for reading NTP server time, but this is not accessible to you as an application developer. Either you implement this yourself, or you could maybe use an open source library, like ios-ntp or HS NTP. I have not used any of them myself. It is probably a good idea to check the position of the device and figure out the timezone, to get a real bulletproof solution.

Here you could read more about the servers and stuff; NIST Internet Time Service

Ideally, you should have a list of servers in the application. If one of them fails, you call the next NTP server in the list.

like image 118
Johan Karlsson Avatar answered Dec 26 '22 11:12

Johan Karlsson