2010-08-19 94 views

回答

1

这应该工作:

NSString *input = @"11:00AM, Saturday August 21, 2010";
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"hh:mma, EEEE MMMM d, yyyy"];
NSDateFormatter *df2 = [[[NSDateFormatter alloc] init] autorelease];
[df2 setDateFormat:@"MMMM yyyy"];
NSDate *date = [df2 stringFromDate:[df dateFromString:input]];


并根据需要格式化你的约会对象。
http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns

+0

如果这是您的正确解决方案,请将其标记为正确答案。 – Simon 2010-08-22 21:44:30

+0

您设置的第一个DateFormatter很好,(df)。我不知道你在用第二个日期格式化程序做什么,但第一个工作正常。谢谢。 – 2010-08-23 01:37:21

1

使用此格式的NSDateFormatter-(NSDate *)dateFromString:(NSString *)string是您想要使用的方法。

+0

有关如何为这样的请求配置日期格式化程序的任何想法? – 2010-08-19 22:42:39