I want compare two dates one would be the current date and other date stored in database. So I want to find out which date is grater from both.
You can use the compare method of the NSDate class
[myDate compare:someOtherDate]
This will return one of three values of type NSComparisonResult...
Check apple documentation .
You can use the following methods,
– isEqualToDate:
– earlierDate:
– laterDate:
– compare:
You can use compare:
method to find which date is earlier or later check the documentation on this
Edit:
NSDateFormatter * formatter= [NSDateFormatter alloc] init];
NSDate *date = [formatter dateFromString:stringDate];
[formatter release];
then compare them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.