I trying to convert a NSString that looks like this:
@"00:00 15 September 2012"
to a NSDate.
I can't figure out what the unicode format needs to be. I am trying this:
@"HH:mm dd MMMM YYYY"
@"HH:mmddMMMMYYYY"
I've been trying to follow the rules here but to no avail.
EDIT:
Paul's answer does work (except for military time problem). I was trying to use Apple's example of how to create a format template like so:
NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"hh:mm dd MMM yyyy" options:0
locale:[NSLocale currentLocale]];
NSDateFormatter* fmt = [NSDateFormatter new];
[fmt setDateFormat:formatString];
This causes everything to spit out null.
However, if I do this:
NSDateFormatter* fmt = [NSDateFormatter new];
[fmt setDateFormat:@"hh:mm dd MMM yyyy"];
All is well in the world. My only guess is that NSLocale doesn't work in simulator?