我正在使用此代码从字符串格式化日期:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"EEEE, dd MMMM yyyy"];
NSDate *dateStart = [dateFormat dateFromString:[thisEvent dateEvent]];
[thisEvent dateEvent]
包含此日期:Saturday, 09 April 2011
我不知道为什么dateStart
包含2010-12-31 23:00:00 +0000
谢谢!!
答案 0 :(得分:2)
当您希望打印日期时,它将是o.k -
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
[dateFormat setDateFormat:@"EEEE, dd MMMM yyyy"];
NSDate *dateStart = [dateFormat dateFromString:@"Saturday, 09 April 2011"];
NSString *formattedDateString = [dateFormat stringFromDate:dateStart];
NSLog(@"%@",formattedDateString);//returns "Saturday, 09 April 2011"//
希望有所帮助
SHANI