ios5 和ios6 时间timeIntervalSinceDate的问题
在ios6中 timeIntervalSinceDate 的处理与ios5中是不一样的
NSString*origDate =@"2012-11-29 19:43:30";
NSDateFormatter*df =[[NSDateFormatter alloc] init];[df setFormatterBehavior:NSDateFormatterBehavior10_4];
[df setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSDate*convertedDate =[df dateFromString:origDate];
[df release];
NSDate* sourceDate =[NSDate date];
NSLog(@"sourceDate: %@", sourceDate);
NSLog(@"convertedDate: %@", convertedDate);
NSTimeInterval ti =[ sourceDate timeIntervalSinceDate:convertedDate];
NSLog(@"interval double: %f", ti);
In iOS 5
interval double:711.113610
in iOS 6
interval double:31623151.242078 解决方法 将日期转换中的YYYY换成 yyyy就好了
timeIntervalSinceNow 的处理也一样
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。