NSDateFormatter doesn’t show time zone abbreviation for “Asia/Kolkata” for the “z” or “zzz” specifier, just the GMT offset

From http://www.cocoabuilder.com/archive/cocoa/310977-nsdateformatter-not-working-on-ios-5.html#311281 The change in parsing of abbreviated time zone names in iOS 5.0 is a result of an intentional change in the open-source ICU 4.8 library (and the open-source CLDR 2.0 data that it uses), a modified version of which is used to implement some of the NSDateFormatter functionality. The issue is this: With … Read more

Convert date string swift

The standard ISO8601 date format with fractional seconds and time zone is yyyy-MM-dd’T’HH:mm:ss.SSSZ let myDate = “2016-06-20T13:01:46.457+02:00” let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale(localeIdentifier: “en_US_POSIX”) // edited dateFormatter.dateFormat = “yyyy-MM-dd’T’HH:mm:ss.SSSZ” let date = dateFormatter.dateFromString(myDate)! dateFormatter.dateFormat = “dd/MM/yyyy” let dateString = dateFormatter.stringFromDate(date) Swift 3: let myDate = “2016-06-20T13:01:46.457+02:00” let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: “en_US_POSIX”) … Read more

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]; }