我有一个包含 date 的 string,格式如下:2014 年 9 月 4 日星期四 10:50:12 +0000
I've got a string containing a date in this format:
Thu, 04 Sep 2014 10:50:12 +0000
您知道如何将其转换为:2014 年 4 月 9 日(dd-MM-yyyy)
Do you know how can I convert it to: 04-09-2014 (dd-MM-yyyy)
当然,使用 Swift
如果上述方法不起作用,这应该可以解决问题:
If the above doesn't work, this should do the trick:
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "US_en")
formatter.dateFormat = "E, dd MMM yyyy HH:mm:ss Z"
let date = formatter.date(from: "Thu, 04 Sep 2014 10:50:12 +0000")
这篇关于在 Swift 中从字符串到 NSDate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
requestLocationUpdate() 抛出的 IllegalArgumentExceptionIllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 抛出的 IllegalArgumentException)
Swift:用户位置附近的地理围栏/地理位置Swift: Geofencing / geolocations near user location(Swift:用户位置附近的地理围栏/地理位置)
Android:使用 LocationManager.requestLocationUpdates() 时如何Android: How to get location information from intent bundle extras when using LocationManager.requestLocationUpdates()(Android:使用 LocationManager.r
Swift 扩展:两个模块中的相同扩展功能Swift Extension: same extension function in two Modules(Swift 扩展:两个模块中的相同扩展功能)
Swift 的标准库和名称冲突Swift#39;s standard library and name collision(Swift 的标准库和名称冲突)
在 Swift 中从 Radius 中的 GeoFire 检索密钥Retrieving Keys From GeoFire within Radius in Swift(在 Swift 中从 Radius 中的 GeoFire 检索密钥)