I have created an application.in the app i start a countdown timer and save current date as double value in database also i save end date according to countdown timer .after closing and return to app i get time form database find the difference between current date and start date and set the countdown according to that.but a problem occurs when i change the time 8 hours ahead then the count down timer behaves differently.how do i find that user has changed time or time zone? by the if i change time zone suppose new delhi to usa it works fine but in the same time zone if i increase/decrease date or time it does not behave as expected.how do i manage this?
Also i had seen a strange problem when increase/decrease date or time the app closes as soon as it launched.i am unable to figure it out
For your timer to be exact, you should just use the end date. I’m not sure why you want to keep the start date.
Here’s an example with a continuous countdown:
endDateshould be a NSDate containing the date when the countdown should reach 0.Because the countdown is adjusted every seconds, you won’t have issues even if the system time or timezone changes.
However make sure you save and restore endDate correctly upon app restart/close (i.e. use a fixed reference always! I would use the timeIntervalSinceReferenceDate and dateWithTimeIntervalSinceReferenceDate: from the NSDate class).