我有一个字符串30-07-2013
我要转换为30 June
。
我正在使用
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/YYYY"];
NSDate *date = [dateFormat dateFromString:@"30-07-1983"];
他们显示回复1984-12-24 18:06:32 +0000
答案 0 :(得分:1)
试试这个
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate *date = [dateFormat dateFromString:@"30-07-2013"];
[dateFormat setDateFormat:@"dd MMM"];
NSString *strDate=[dateFormat stringFromDate:date];
NSLog(@"strDate : %@",strDate);
答案 1 :(得分:0)
请试试这个
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
NSDate *date = [dateFormat dateFromString:@"30-07-1983"];
NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:date];
NSLog(@"%d %@",(int)[components day],[[[NSDateFormatter new] monthSymbols] objectAtIndex:(components.month-1)]);