0

とにかく、現在の時刻が2つの時刻の間にあるかどうかを確認できますか?

現在の時刻 = 午前 12:00
時刻 A: 午前 8:00
時刻 B: 午後 3:00

これは true を返しますが、そうではありません:
現在の時刻: 1:00 PM
A = 1:00 AM
B = 2:00 AM

4

1 に答える 1

3

次の行に沿って何かを行うことができます。

NSDate *timeA, *timeB; // Whatever and however you want to set these;
NSDate *now = [NSDate date];

If([now compare:timeA] == NSOrderedDescending && [now compare:timeB] == NSOrderedAscending)
    // then now is between timeA and Time B
于 2012-09-02T22:40:25.627 に答える