我已經嘗試了很多次將字符串2013-01-27T02:31:47+08:00
轉換成NSDate。我通過蘋果發現了formatting guide並複製了它的代碼並嘗試了,但它不起作用。如何格式轉換字符串2013-01-27T02:31:47 + 08:00到NSDate
NSDateFormatter *rfc3339DateFormatter = [[NSDateFormatter alloc] init];
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[rfc3339DateFormatter setLocale:enUSPOSIXLocale];
[rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
[rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:8]];
// Convert the RFC 3339 date time string to an NSDate.
NSDate *date = [rfc3339DateFormatter dateFromString:@"2013-01-27T02:31:47+08:00"];
thx :)'ZZZZZ'它適用於我:) – code4j