Hi, I have a time of NSString type. i wonder get the day, but i find somethine strange.
NSString *strTime = @"2010-05-14 16:00:01";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *oldDate = [formatter dateFromString:strTime];
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:flags fromDate:oldDate];
int day = [components day];
When NSString *strTime = @"2010-05-14 16:00:01" the day is 15,and when NSString *strTime = @"2010-05-14 16:00:00" the day is 14.I want to know why?