I have a date timestamp in milliseconds:
145146240000
I create an NSDate object from that timestamp:
NSTimeInterval seconds = [@"1451462400000" doubleValue] / 1000.0f;
NSDate *transactionDate = [NSDate dateWithTimeIntervalSince1970:seconds];
NSLog(@"%@", transactionDate);
I log the value of transactionDate
: 2015-12-30 08:00:00 +0000
I then output this date using an NSDateFormatter
:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"d MMMM YYYY"];
NSLog(@"%@", [dateFormatter stringFromDate:transactionDate]);
This incorrectly outputs the year to be 2016!:
30 December 2016
How can this be? My local timezone is GMT+2 so if anything it could be off by two hours when parsed by the formatter but not an entire year!