I have been going up and down through all kinds of reference docs and examples over the web but I just can't get how to get what day, month, year, hours, minutes will it be for a given timestamp in Objective C. Any ideas? The code I'm using for the purpose is like this:
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1286181000]; unsigned int compFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit; NSDateComponents *weekdayComponents = [[NSCalendar currentCalendar] components:compFlags fromDate:date]; NSLog(@"%d %d, %d:%d", [weekdayComponents day], [weekdayComponents month], [weekdayComponents hour], [weekdayComponents minute]); [date release]; [weekdayComponents release];
Although the timestamp is for a day in October, the output gives me 19th of December.