获取今天的日期
-(NSString *)getDate{
NSDateFormatter*formatter = [[NSDateFormatteralloc]init];
[formatter setDateFormat:@"YYMMdd"];
NSString *locationString=[formatter stringFromDate: [NSDate date]];
[formatter release];
return locationString;
}
获取前一天日期
-(NSString *)getPredate:(NSString *)strDate
{
NSDateFormatter*formatter = [[NSDateFormatteralloc]init];
[formatter setDateFormat:@"YYMMdd"];//MAC10.8的系统注意“YY”要小写,否则会减一年,iOS暂时不区分
NSDate *locationdate=[formatter dateFromString:strDate];
NSDate *predate = [NSDatedateWithTimeInterval:-24*60*60 sinceDate:locationdate];
NSString *locationString = [formatter stringFromDate:predate];
[formatter release];
return locationString;
}