swiftdate

SwiftDate - string to date

吃可爱长大的小学妹 提交于 2020-01-06 05:43:49
问题 I use the SwiftDate library but I can't transform my string to date. This code return null let date = "Tue, 19 Sep 2017 15:43:57 GMT".date(format: .custom("EEE, dd MMM yyyy HH:mm:ss zzz")) Would anyone know why? 回答1: This code works now : let region = Region(tz: TimeZoneName.gmt, cal: CalendarName.gregorian, loc: LocaleName.englishUnitedStates) let date = "Tue, 19 Sep 2017 15:43:57 GMT".date(format: .custom("EEE, dd MMM yyyy HH:mm:ss zzz"), fromRegion: region) Thank you for your help! 来源: