NSDateFormatter无法识别IST时区。 确认以下日期
let dateString = "Jun 10, 2015 @ 12.30 AM PDT"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMM-dd-yyyy @ hh-mm-a-zzz"
let date = dateFormatter.dateFromString(dateString)
但无法识别IST时区的时间。
let dateString = "Jun 10, 2015 @ 12.30 AM IST"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMM-dd-yyyy @ hh-mm-a-zzz"
let date = dateFormatter.dateFromString(dateString)
IST时区的日期为零。
答案 0 :(得分:0)
作为一种解决方法,这有助于:
let dateString = "Jun 10, 2015 @ 12.30 AM"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMM-dd-yyyy @ hh-mm-a"
dateFormatter.timeZone = NSTimeZone(abbreviation: "IST")
let date = dateFormatter.dateFromString(dateString)