比较NSDate中的时间 [英] Comparing time in NSDate
本文介绍了比较NSDate中的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图比较两个NSDate对象的时间,但得到错误的答案。我认为这是因为当使用NSDate比较方法它也包括日期。我只想忽略日期和比较时间。如何做到这一点?
I am trying to compare the time from two NSDate objects but am getting the wrong answer. I think it is because when using the NSDate compare methods it is also including the date. I just want to ignore the date and compare the times. How can this be done?
推荐答案
很好,你可以使用NSCalendar的 - (NSDate *)dateFromComponents :(NSDateComponents *)comps
well, you can always use NSCalendar's - (NSDate *)dateFromComponents:(NSDateComponents *)comps
这篇关于比较NSDate中的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文