将字符串“2015-04-10”格式化日期转为NSDate类型
NSString*timeStr =@"2015-04-10";NSDateFormatter*formatter = [[NSDateFormatteralloc] init];formatter.dateFormat=@"yyyy-MM-dd";formatter.timeZone= [NSTimeZonedefaultTimeZone];NSDate*date = [formatter dateFromString:timeStr];// 2015-04-09 16:00:00 +0000NSLog(@"%@", date);
网友评论