gpt4 book ai didi

iphone - 将当前时间与固定时间进行比较 05 :00:00 PM

转载 作者:行者123 更新时间:2023-12-03 19:42:04 24 4
gpt4 key购买 nike

如何将当前时间 [NSDate date] 与固定时间 05:00:00 PM 进行比较。

下午 05:00 是否已经过去了。我只需要对此进行 BOOL 检查。

最佳答案

- (BOOL)past5pm
{
NSCalendar *gregorianCalender = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *components = [gregorianCalender components:NSHourCalendarUnit fromDate:[NSDate date]];

if([components hour] >= 17) // NSDateComponents uses the 24 hours format in which 17 is 5pm
return YES;

return NO;
}

关于iphone - 将当前时间与固定时间进行比较 05 :00:00 PM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5880627/

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