如何在 iPhone 中获取时差
我有 2 个包含时间值的数组。它们采用以下格式。 mm:ss:数百秒。我想获得数组中两个 [lastObjects] 之间的差异。 NSDate 不起作用,因为最后一个值以百分之一秒为单位。
一个问题。如果第二个日期大于第一个日期,它会给我一个负数,例如 -01:10:00 吗?
I have 2 arrays with time values in it. They are in the following format. mm:ss:hundreds of a sec. I want to get the difference between the two [lastObjects] in the arrays. NSDate is not working because the last value is in hundredsth of a sec.
A question. If the second date is larger than the first will it give me a negative number like -01:10:00 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题有两个部分,解析时间并获取差异:
Your problem has two parts, parsing the time and getting the difference:
NSDate
应该适合你,使用timeIntervalSinceDate:
,返回毫秒精度的时间间隔。NSDate
should work for you, usetimeIntervalSinceDate:
, which returns a time interval which has millisecond precision.