將字符串“2015-04-10”格式化日期轉(zhuǎn)為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);