What format is this date?

Go To StackoverFlow.com

0

I'm trying to write an NSDateFormatter format for this date. What format do I need to use to parse this string into an NSDate?

2007-07-01T00:00:00-04:00

2012-04-05 16:07
by Moshe


1

This is RFC 3339 date. There is an example that parses this format right in the Apple documentation: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html

rfc3339DateFormatter = [[[NSDateFormatter alloc] init] autorelease];
enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
[rfc3339DateFormatter setLocale:enUSPOSIXLocale];
[rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
[rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
date = [rfc3339DateFormatter dateFromString:rfc3339DateTimeString];
2012-04-05 16:10
by kuba
Ads