一.字符串转换成NSData
NSDateFormatter*df = [[NSDateFormatter alloc]init];//格式化
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
[df setLocale:[[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"] ];
NSDate*date =[[NSDate alloc]init];
date =[df dateFromString:timeStr];
二.NSData转换成字符串
NSDateFormatter* df2 = [[NSDateFormatter alloc]init];
[df2 setDateFormat:@"MM月dd日 HH:mm"];
NSString* str1 = [df2 stringFromDate:date];
网友评论