Formatting NSDate

I am trying to convert a string to NSDATE, fortunately, unfortunately.

Friday, October 22, 11:26:45 ET 2010

I know the formatting options (http://sree.cc/ objective-c / nsdate-format-string-in-objective-c), but I can't get it to work.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"???????"];

is anyone

+3
source share
1 answer

Date format specifiers .

So, you probably need something like:

[dateFormatter setDateFormat:@"eeee, MMMM dd, HH:mm:ss z yyyy"];
  • eeee - The local time of the week is registered.
  • MMMM - recorded month
  • dd - day of the month without leading zeros
  • HH - hour of the day (24 hours format)
  • mm - minutes of an hour (with an initial zero)
  • ss - seconds of a minute (with an initial zero)
  • z - time zone (short time on the wall)
  • yyyy - calendar year
+5
source

Source: https://habr.com/ru/post/1785285/


All Articles