Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to synchronize iPhone time with the server

I have a client server model where server will send some data which has date parameters and iPhone will need to render it. Server and iPhone will resides in different timezones. So I need to synchronize times in both. Let say user has done some activity at "07/18/2011/04 /45/EDT" (server time). From the iPhone end I need to convert this date string into a NSDate object.

What is the best way to achieve this.

Thank you

like image 406
Dilshan Avatar asked Jul 18 '11 12:07

Dilshan


People also ask

How do I sync my iPhone internet time?

Go to Settings > General > Date & Time. Turn on any of the following: Set Automatically: iPhone gets the correct time over the network and updates it for the time zone you're in. Some networks don't support network time, so in some countries or regions, iPhone may not be able to automatically determine the local time.

What time server does iPhone use?

Yes it uses standard port 123 UDP.


1 Answers

Sorry for the late response, just looked for "NSDate Sync to Server" on google and got here. I got stuck with the same issue and written this nice little category that helps.

It can return an NSDate object synced to any web server with only a single HTTP Request (per-session).

https://github.com/freak4pc/NSDate-ServerDate

If you have any questions feel free to let me know.

like image 129
Shai Mishali Avatar answered Oct 23 '22 03:10

Shai Mishali