I have an a string in UTC which i want to convert to NSDate. Somehow Im getting 30 minutes error
The string is
2012-04-10T00:00:00+05:30
the converted date is
2012-04-09 19:00:00 +0000
where as it should have been
2012-04-09 18:30:00 +0000
Im using this function to convert string to date
- (NSDate *)parseRFC3339Date{
NSDateFormatter *rfc3339TimestampFormatterWithTimeZone = [[NSDateFormatter alloc] init];
[rfc3339TimestampFormatterWithTimeZone setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
NSDate *theDate = nil;
NSError *error = nil;
if (![rfc3339TimestampFormatterWithTimeZone getObjectValue:&theDate forString:self range:nil error:&error]) {
NSLog(@"Date '%@' could not be parsed: %@", self, error);
}
[rfc3339TimestampFormatterWithTimeZone release];
return theDate;
}
I ran into ISOdateFormatter here http://boredzo.org/iso8601unparser/ which works perfectly. Fund it better than modifying incoming date strings.