HI,我有一个字符串2011-05-13T00:00:00我想以MMM d,yyyy格式转换此字符串。 任何帮助?
答案 0 :(得分:1)
您应该查看NSDateFormatter
的参考文档,它完全符合您的要求:http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html
答案 1 :(得分:1)
我不在我的Mac上,但这应该让你先行一步:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'"];
NSDate *originalDate = [dateFormatter dateFromString:originalDateString];
[dateFormatter setDateFormat:@"MM' 'DD','yyyy"];
NSString *formattedDateString = [dateFormatter stringFromDate:originalDate];
[dateFormatter release];
答案 2 :(得分:0)
使用此代码
NSDateFormatter * df = [[NSDateFormatter alloc] init];
[df setDateFormat:@“yyyy-MM-dd hh:mm:ss a”];
NSDate * myDate = [df dateFromString:myDateAsAStringValue];
答案 3 :(得分:0)
onResponse