1

How would I format a NSDateFormatter to create a date from the following format?

Sat May 16 13:45:36 2015

The part of Sat May 16 is the part that I am unsure how to do

I know the last part would be HH:mm:ss yyyy

Clip
  • 3,018
  • 8
  • 42
  • 77
  • 2
    Have you checked [the spec](http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns)? – Hot Licks May 15 '15 at 19:52
  • This is a good reference: http://waracle.net/iphone-nsdateformatter-date-formatting-table/ – Otávio May 15 '15 at 21:08

1 Answers1

0
let dateString = "Sat May 16 13:45:36 2015"
let df = NSDateFormatter()
df.dateFormat = "E MMM dd HH:mm:ss yyyy"
df.dateFromString(dateString)   // "May 16, 2015, 1:45 PM"

You should take a look at this answer also.

Community
  • 1
  • 1
Leo Dabus
  • 229,809
  • 59
  • 489
  • 571