比较 NSDate 中的时间

发布于 2024-09-24 16:50:21 字数 89 浏览 0 评论 0原文

我试图比较两个 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹沉浮 2024-10-01 16:50:21

好吧,你总是可以使用 NSCalendar 的 - (NSDate *)dateFromComponents:(NSDateComponents *)comps

well, you can always use NSCalendar's - (NSDate *)dateFromComponents:(NSDateComponents *)comps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文