Edit AllPages

see also NSDateFormattingAndBindings

I have a NSDateFormatter attached to a text field in InterfaceBuilder with the format %d %b %Y and NaturalLanguage allowed.

Works fine, producing 05 Feb 2005 when I enter ‘today’, etc.

Except I can’t see a way of giving it a locale when it reads the string, so I get 02 Mar 2005 instead for 05/02/05.

I’m sure I must be missing something very obvious before I start subclassing?

@implementation MyDateFormatterDMYSubclass


A bit of a hack, but it seems to work.

Running 10.3.2, so not sure where else this is broken - but doing the NSCalendarDate custom essays custom essays formatting example using %I, such as the one in the class docs from apple [now descriptionWithCalendarFormat:@”%a %m/%d/%y %I:%M %p”];

always pads the hour with a ‘0’ if the hour is less than 10; analysis essay so one would always see: �Tues 3/24/01 03:30 PM�

not �Tues 3/24/01 3:30 PM� as promised

is anyone else seeing this? essay writing Yes - I thought that was how it was supposed to work - in the formatter listing at [] it says:

%I  Hour based on a 12-hour clock as a decimal number (01-12)    and see

Why not simply make it a string value, return the intValue buy research paper and then place it back in a string or some other unorthodox but workable hack?

This is fixed by using the formatting code %1I. This strips the leading zero, a little known fact about strftime and NSDate formatting. – TimothyHatcher

NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setFormatterBehavior:NSDateFormatterBehavior10_4]; [df setDateFormat:@”EEE, d MMM yyyy HH:mm:ss”]; NSString *strDate = @”Mon, 6 Jul 2009 20:57:58”; NSDate *date = [df dateFromString:strDate]; NSLog(@”date: %@ <> ‘%@’”, date, strDate);

This code doesn’t work, date is always (null). Why??? � beefon