-(NSString*)getTimeStringWithSp:(NSString *)sp{
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneWithName:@"beijing"];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"MM月dd日"];
//[formatter setDateFormat:@"yyyy年MM月dd日 HH:mm:ss"];
NSDate* endDate = [NSDate dateWithTimeIntervalSince1970:sp.doubleValue];
NSDate*nowDate=[NSDate date];
NSCalendar*gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
unsigned int unitFlags = NSDayCalendarUnit;
NSDateComponents*comps = [gregorian components:unitFlags fromDate:nowDate toDate:endDate options:0];
NSString* dateString = [formatter stringFromDate:endDate];
NSLog(@"月日:%@",dateString);
return[NSString stringWithFormat:@"%d",[comps day]];
}
直接调用这个方法就OK了,传入的是时间戳字符串,返回来的是标准时间差