IOS determines whether the current time is in a certain period of time.
/*** Determine whether the current time is in a certain period of time ** @ param startTime start time * @ param expireTime end time */-(BOOL) validateWithStartTime :( NSString *) startTime withExpireTime :( NSString *) expireTime {NSDate * today = [NSDate date]; NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init]; // time format, which has encountered a pitfall, it is recommended that the time HH should be capitalized. The phone can be formatted in 24 hours or 12 hours. [dateFormat setDateFormat: @ "yyyy-MM-dd't'hh: mm"]; NSDate * start = [dateFormat dateFromString: startTime]; NSDate * expire = [dateFormat dateFromString: expireTime]; if ([today compare: start] = NSOrderedDescending & [today compare: expire] = NSOrderedAscending) {return YES;} return NO ;}
If you did not see this article in wb145230 blog,Click to view Original Text.