swiftnsformatter

Swift NSDateFormatter using a quotation mark


This code works:

        let fmt = NSDateFormatter()
        fmt.dateFormat = "MMM d yy"
        return fmt.stringFromDate(mydate)

Returns Dec 31 10

But if I try to get this Dec 31 '10 using

        fmt.dateFormat = "MMM d 'yy"

It doesn't work, get Dec 31 yy

How can you include the quote?


Solution

  • Use:

    fmt.dateFormat = "MMM d ''yy"