I want to check two dates: one is in my plist in the following NSString
format 2013-08-03 12:26:33 +0000
But, I only need 2013-08-03
, how can I remove rest of the time values? Please help me.
I am checking dates using following code, it's working for me. But I only need to retrieve the date part in 2013-08-03 12:26:33 +0000
NSString *start = @"2013-08-03 ";
NSString *end = @"2013-08-05";
NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"yyyy-MM-dd"];
NSDate *startDate = [f dateFromString:start];
NSDate *endDate = [f dateFromString:end];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit
fromDate:startDate
toDate:endDate
options:0];
NSLog(@"%ld", [components day]);