I want to format my date as follows:
Mon, Apr 14 '09
The dateFormat
I'm setting for my NSDateFormatter
is EEE, MMM dd 'yy
but it shows:
Mon, Apr 14 'yy
If I take out the single quote before the year, I get the last two digits of the year but it's not obvious that it's the year because the single quote is gone. Help?
I've also tried putting '''
, '\''
, and '\'''
before 'yy' but it doesn't work, although the last two produced 'yy
and ''09
I solved my problem to the format yyyy-MM-dd'T'HH:mm:ss. SSS'Z' (e.g 2018-06-15T00:00:00.000Z) with this: func formatDate(date: String) -> String { let dateFormatterGet = DateFormatter() dateFormatterGet. dateFormat = "yyyy-MM-dd'T'HH:mm:ss.
A formatter that converts between dates and their textual representations.
From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns:
In patterns, two single quotes represents a literal single quote, …
In your case:
[formatter setDateFormat:@"EEE, MMM dd ''yy"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With