Skip to content

Instantly share code, notes, and snippets.

@Fogh
Created March 27, 2014 12:18
Show Gist options
  • Save Fogh/9806281 to your computer and use it in GitHub Desktop.
Save Fogh/9806281 to your computer and use it in GitHub Desktop.
WCF JSON Date to NSDate
- (NSDate *)deserializeJsonDateString:(NSString *)jsonDateString
{
NSInteger offset = [[NSTimeZone defaultTimeZone] secondsFromGMT];
NSInteger startPosition = [jsonDateString rangeOfString:@"("].location + 1;
NSTimeInterval unixTime = [[jsonDateString substringWithRange:NSMakeRange(startPosition, 13)] doubleValue] / 1000;
return [[NSDate dateWithTimeIntervalSince1970:unixTime] dateByAddingTimeInterval:offset];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment