NSDateFormatter "Month" in 3 letters instead of full word NSDateFormatter "Month" in 3 letters instead of full word ios ios

NSDateFormatter "Month" in 3 letters instead of full word


Have you tried: [formatter setDateFormat:@"dd-MMM-YYYY HH:mm"]; and then [formatter stringFromDate:someNSDate];


IF you get the two things in the wrong order, you don't get the expected output.

[formatter setDateFormat:@"MMM"];[formatter setDateStyle:NSDateFormatterMediumStyle];

does NOT give the same results as:

[formatter setDateStyle:NSDateFormatterMediumStyle];[formatter setDateFormat:@"MMM"];

(The second of these two snippets is now happily handing out Sep Oct etc in my app)


In SWIFT

let dateFormatter = NSDateFormatter()dateFormatter.dateFormat = "dd MMM yyyy HH:mm"dateFormatter.stringFromDate(NSDate())