iPhone NSDateFormatter Timezone Conversion

To process the time zone with the colon in it, you just need to use 5 ‘Z’s. This is a pretty common date format, the ISO-8601 format. This will only work on iOS 6.x+

-(NSDate *) dateFromString:(NSString *)string {

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];

    return [formatter dateFromString:string];
}

Leave a Comment