//获取当地时间
- (NSString*)getCurrentTime {
NSDateFormatter *formatter = [[NSDateFormatteralloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString *dateTime = [formatter stringFromDate:[NSDatedate]];
returndateTime;
}
//将字符串转成NSDate类型
- (NSDate*)dateFromString:(NSString*)dateString {
NSDateFormatter *dateFormatter = [[NSDateFormatteralloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *destDate= [dateFormatter dateFromString:dateString];
return destDate;
}
//传入今天时间返回明天时间
- (NSString*)GetTomorrowDay:(NSDate*)aDate {
NSCalendar *gregorian = [[NSCalendaralloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *components = [gregorian components:NSCalendarUnitWeekday|NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDayfromDate:aDate];
[components setDay:([components day]+1)];
NSDate *beginningOfWeek = [gregorian dateFromComponents:components];
NSDateFormatter *dateday = [[NSDateFormatteralloc] init];
[dateday setDateFormat:@"yyyy-MM-dd"];
return[dateday stringFromDate:beginningOfWeek];
}