0
我目前有2个日期选择器,用户可以选择开始日期和结束日期。我想知道两分钟或几小时之间的差异。这些值将被存储到我假设的2个NSDate变量中?那么我怎样才能减去2个NSDates并得到一个浮点值。非常感谢你。减去2 Datepickers
我的回答
NSTimeInterval timeInseconds1 = [[startTimePicker date] timeIntervalSince1970];
NSTimeInterval timeInseconds2 = [[endTimePicker date] timeIntervalSince1970];
float difference = timeInseconds2 - timeInseconds1;
NSLog(@"%f", difference);
非常感谢你,它的工作原理!我发布了我的答案。 – 4GetFullOf