I am trying to convert a date from a String to NSDate with the following code:
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "E, dd MMM yyyy, KK:mma"
date = dateFormatter.dateFromString(strDate)
Converted Tue, 12 Jan 2016, 7:30am to nil with the formatter E, dd MMM yyyy, KK:mma
The typical reason is that your device is not set to English language. Note that parsing strings like Tue
or Jan
is language specific. That means you have to make sure the formatter has a correct language set, e.g.:
dateFormatter.locale = NSLocale(localeIdentifier: "en")