I’m having issues with my webserver and iPhone app, considering the timezone. It’s all set well and I know how to change it, but I’m just wondering what is the best approach considering the following case.
The iPhone app I am working on uses several NSDate objects to store datetime values. These get exchanged with the webserver (including database) that uses timestamps for comparing dates. For exporting the NSDate object I usually convert it to a string by formatting NSDate timeIntervalSince1970. I don’t know what the exact timezone of this interval is, but I’m guessing it’s the locale (if not set otherwise).
My webserver is set to CET (UTC-1). When the iPhone app converts the interval to, say, UTC-3, and the database compares it with a UTC-1 date, you obviously get a gap.
What’s the best approach here? How does timeIntervalSince1970 handle timezones? I’m well aware that NSDate has no timezone (a timezone is merely representation), but since I’m converting from and to unix time through a string, I think it matters.
Any help is greatly appreciated.
Kind regards,
Reinder
Just always use UTC time. Both on client and server.