String to nsdate from Swift

I have a string containing a date in this format:
Thursday, September 4, 2014 10:50:12 0000

Do you know how to convert it to:
April 9, 2014
(DD-MM-YYYY)

Of course, use Swift
Thank you

If the above method does not work, this should solve the problem:

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")

I have a character containing a date in this format String:
Thursday, September 4, 2014 10:50:12 0000

Do you know how to convert it to:
April 9, 2014
( DD-MM-YYYY)

Of course, use Swift
Thank you

If the above method does not work, this should be solved Question:

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")

Leave a Comment

Your email address will not be published.