iosdevnyc
iosdevnyc

Reputation: 1871

Syncing data from iphone to the server Datetime question

I want sync data from iphone to the webs server. My question is how can I know which data is new? the only way I see this is by making a datafield for each record on the server and the iPhone, but how about if the Iphone user is in a different timezone or his datetime is different from the server datetime.

Upvotes: 0

Views: 119

Answers (1)

Chip Coons
Chip Coons

Reputation: 3201

Store all of your dates in GMT on both the server and device. There are several methods for getting GMT easily in Objective-C. The device will determine time-zone based on location. If you need to convert to local time, you can get the date by using the NSTimeZoneClass:

[NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone defaultTimeZone] secondsFromGMT]]

Check out the docs on Date and Time Programming for additional assistance.

Upvotes: 1

Related Questions