简体   繁体   中英

Formatting date with NSDateFormatter on the iPhone

Since initWithDateFormat:allowNaturalLanguage: is now deprecated,

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] initWithDateFormat:@"%B %d, %Y" allowNaturalLanguage:NO] autorelease];

How does one currently format with the same formatting string using 2.2.1?

Pl. use the following steps:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];

Just manually assign to dateFormat and only use "init" instead of "initWithDateFormat:...".

The Natural Language stuff is what appears to be deprecated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM