nsdateformatter - how to convert "Tue, 14 Jul 2015 15:00:00 +0000" in iOS 8.1 -


i've tried convert string nsdate way:

nsstring *str = @"tue, 14 jul 2015 15:00:00 +0000";  nsdateformatter* formatter = [[nsdateformatter alloc] init];  [formatter setdateformat:@"eee, dd mmm yyyy hh:mm:ss zzzz"];  nsdate* adate = [formatter datefromstring:str];  [formatter setdateformat:@"mmm dd,yyyy hh:mm:ss"];  nslog(@"%@", [formatter stringfromdate:adate]); 

but null, real way?

i have tried , should work result :

jul 14,2015 16:00:00 (based on time zone) 

here code:

nsstring *str = @"tue, 14 jul 2015 15:00:00 +0000";  nsdateformatter* formatter = [[nsdateformatter alloc] init];   [formatter setdateformat:@"eee, dd mmm yyyy hh:mm:ss z"];  nsdate* adate = [formatter datefromstring:str];  [formatter setdateformat:@"mmm dd,yyyy hh:mm:ss"]; //formatter.timezone = [nstimezone timezonewithabbreviation:@"gmt"]; if want avoid converting time current timezone  nslog(@"%@", [formatter stringfromdate:adate]); 

date format patterns


Comments