gpt4 book ai didi

iphone - 如何比较当前和手动 NSDate

转载 作者:行者123 更新时间:2023-11-28 22:53:41 27 4
gpt4 key购买 nike

有一个函数,其中指定选项 NSDate 手动放置。如何防止使用时间参数小于当前时间的函数执行?这个我试过了

if ([currentDate timeIntervalSinceDate: myTime] < 0)

但不幸的是有时它不起作用提前致谢。

最佳答案

另一种选择是使用 timeIntervalSince1970

将日期转换为 timeIntervals
int interval1 = [date1 timeIntervalSince1970];
int interval2 = [date2 timeIntervalSince1970];

if(interval1 > interval2) //etc...

关于iphone - 如何比较当前和手动 NSDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11261215/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com