IOS determines whether the current time is in a certain period of time.

Source: Internet
Author: User

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.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.