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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With