[英]correct format for Swift NSDateFormatter
I have this time format 2016-09-06T12:44:00.118Z 我有这种时间格式2016-09-06T12:44:00.118Z
What is the correct format for NSDateformatter? NSDateformatter的正确格式是什么? With below format it doesn't seems to be calculating the correct time.
使用以下格式,它似乎无法计算正确的时间。
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
This last 118Z part of the date string is probably the time zone. 日期字符串的最后118Z部分可能是时区。 So What dateFormat could be used here instead .SSSZ ?
那么在这里可以使用什么dateFormat代替.SSSZ?
I couldn't find a way to construct a proper formatter string with the help of this, 我无法借助这种方法来构造适当的格式化程序字符串,
http://userguide.icu-project.org/formatparse/datetime http://userguide.icu-project.org/formatparse/datetime
Try this... 尝试这个...
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.timeZone = NSTimeZone(name: "UTC")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.