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!



来源:https://stackoverflow.com/questions/46305634/swiftdate-string-to-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!