Today, I encountered a very strange problem when writing a swift demo. I used UIDatePicker to select the time on the presented page, and then transferred the obtained time back to the original main interface. The result was a problem Appears: The acquisition time of page B is normal, but the time after page A is returned is 9 hours less. I was puzzled, so I found some answers on Google and said it was like this:
time.timeZone = NSTimeZone.systemTimeZone() time.calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar)
let timeZone = NSTimeZone.systemTimeZone()let seconds = timeZone.secondsFromGMTForDate(addObject.time.date)let correctDate = addObject.time.date.dateByAddingTimeInterval(Double(seconds))
Although the problem was solved, I still don’t understand why. Could this be the reason for the XCode GM version (unlikely~). I hope those who know the reason will give me some advice and we can make progress together!