I'm making a Turn-Based game, and trying to figure out when the last turn happened. I get it to work by doing this:
NSDate *lastTurn = [NSDate date];
(When sending turn)
... And then calculate the difference for the next player when it's his/her turn:
NSTimeInterval *diff = [lastTurn timeIntervalSinceNow];
This works great if both users have the same time settings. But if one player have their iphone set to a different timezone or have the time set all wrong, the result will be wrong.
How can i fix this?
Many thanks
Use GMT time instead of local time.
Maybe something like this (I haven't tried):
NSInteger sec = [[[NSCalendar currentCalendar] timeZone] secondsFromGMT];