Swift_ will uidatepicker reach the difference between the spread of the page in a few hours

Source: Internet
Author: User
Tags cst time

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.