标签:style blog class code c java
//创建当前日期 NSDate *date = [NSDate date]; //创建日期格式类 NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init]; //设置日期格式 [dateFormat setDateFormat:@"yyyy/MM/dd HH:mm:ss"]; //获取招聘信息的创建日期 NSDate *createDate =[dateFormat dateFromString:_recruit.createTime]; NSLog(@"recruit.createTime==》%@ date==>:%@ - createDate:%@",recruit.createTime,date,createDate); NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; unsigned int unitFlags = NSDayCalendarUnit; NSDateComponents *comps = [gregorian components:unitFlags fromDate:createDate toDate:date options:0]; int days = [comps day]; NSLog(@"天数===%d",days);
打印:
recruit.createTime==》2014/5/7 14:57:49 date==>:2014-05-15 07:45:34 +0000 - createDate:2014-05-07 06:57:49 +0000
日期字符串转换 and 两个日期相减,布布扣,bubuko.com
标签:style blog class code c java
原文地址:http://www.cnblogs.com/hw140430/p/3730153.html