Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
What is the most reliable way of getting the current date from an online server in a format you can use easily in ios?

[edit]
Maybe I should explain why I don't wish to use for instance:
Code:
NSDate *today1 = [NSDate date];
It's simply because I don't intend to allow the user to manipulate that value by changing the date on his/hers device.

Perhaps it's possible to force the NSDate to be fetched online instead of from the system date?
 
Last edited:
Pretty much any web page has HTTP headers that include the date and time. So simply pick a trusted server (it doesn't even need to be one you own or control), and issue an HTTP request. The headers will contain the date. It doesn't need to be "most reliable". It just needs to be fairly competent and not trivially spoofable.

Personally, I'd pick a small and simple web page, from a widely accessible service, perhaps something located on the Amazon S3 service, or a Wikipedia page for some small item.

Of course if you don't have an active internet connection, none of this will work. So you should be thinking about the fallback strategy for what your code will do then. Because if the date matters that much to you, someone will find some other way to trick the app into using some other date.
 
Last edited:
Thanks for your suggestions.

I found a way that suits me better, however, since I'm using parse.com.

I simply update an object in the database, and then retrieve the "updatedAt"-value from that object. Works great :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.