I am parsing a JSON file which contains a timestamp. I want to convert this timestamp into an NSDate.
My code :
NSString *depart=[alternates valueForKey:@"startTime"];
NSTimeInterval intervaldep=[depart doubleValue];
NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:intervaldep];
But I am getting wrong date, e.g.: 44135-04-01 03:20:00 +0000 for time stamp 1330606668000.
If any one has any idea please help.
Thank you.
Your timestamp contains milliseconds, just divide your timestamp by 1000 (i.e. trim the last three zeros) and you should be fine.