Today, write Swift demo when it came to a very wonderful question, I again present use the page out Uidatepicker select time, and then back to the original main interface time, the result of the problem: B page Normal time, passed back a page after 8 hours less time. The solution is not to be baffled. Google has found some answers to say this:
Time.timezone = Nstimezone.systemtimezone () Time.Calendar = Nscalendar (Calendaridentifier:nsgregoriancalendar)
After the addition has no effect, or the same difference of 8 hours. Later there was a second way to solve this:
Let TimeZone = Nstimezone.systemtimezone () Let seconds = timezone.secondsfromgmtfordate (addObject.time.date) let Correctdate = AddObject.time.date.dateByAddingTimeInterval (Double (seconds))
Although the problem has been overcome, but still a little unclear why this situation, is the XCode GM version of the reason (not likely ah ~).
Want to know what the reason for the children's shoes advice, common progress!
------------2014.09.20 Changes--------------------
Today, the official version of Xcode 6.0.1, from the B-page datepicker.date to a page has not been less than 8 hours of problems. But the print out time is not the same as the debug see time, the same 8 hours apart, debug see CST time. And the printing time may not be CST time, should be caused by time zone problems, at the moment do not know how to print out the time and the system shows the time consistent.
References: ios-nsdate difference 8 hours
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Swift_ will uidatepicker reach the difference between the spread of the page in a few hours