I converting this string 2016-12-14T03:59:59Z
to a NSDate using this way
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
[formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
[formatter dateFromString:rawDate];
When I log this instance it's show 2016-12-14 03:59:59 +0000
but when I try to get the day from the instance using this way
NSDateComponents *components = [[[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian] components:NSCalendarUnitDay fromDate:nsDateInstance];
//Return 13
[components day];
And I don't know why. I've also tried using the CurrentCalendar
but got the same result.
Thanks in advance.