1
votes

Date string: Fri, 03 Oct 2014 21:14:01 EST

I can get NSDate from above string using below code in iOS 7:

@"EEE, dd MMM yyyy HH:mm:ss z"

While in iOS 8 I am getting nil date and I have tried following formats to get NSDate but no luck.

@"EEE, dd MMM yyyy HH:mm:ss Z" @"EEE, dd MMM yyyy HH:mm:ss ZZZ"

Can anybody help me on this?

Tushar

2

2 Answers

0
votes

This is a bug in iOS 8.0.2. If you try the same code on iOS 8 it works file. File a bug report so Apple can fix it.

0
votes

This code works fine for me for such a situation:

NSString *dateWithInitialFormat = @"Fri, 03 Oct 2014 21:14:01 EST";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss z"];
NSDate *date_creaet = [dateFormatter dateFromString:dateWithInitialFormat];
[dateFormatter setDateFormat:@"ccc,MMMM dd,yyyy"];
NSString *dateWithNewFormat = [dateFormatter stringFromDate:date_creaet];