nsdate - iOS converting string to date and time...Eastern Standard Time suffix -


i have strings being output so:

7/16/15 10:00 eastern standard time

when try convert them dates, using code:

- (nsdate*) convertstringtodateandtime : (nsstring*) strtoconvert {      nsdateformatter* dateformatter = [[nsdateformatter alloc] init];     [dateformatter setdateformat:@"mm/dd/yy hh:mm aa"];     [dateformatter settimezone:[nstimezone timezonewithname:@"est"]];     nslog(@"%@", [dateformatter datefromstring:strtoconvert]);       return [dateformatter datefromstring:strtoconvert]; } 

i null result. have strip of eastern standard time suffix?

thanks

edit: here's console log output, first value nsstring trying convert, second 1 conversion result, after modifying code glorfindal suggested.

2015-07-16 14:39:07.101 xxxxxxxxxxxx[23685:9316155] 7/16/15, 1:08:00 pm eastern daylight time::::(null) 

you have make sure dateformat matches input string exactly, including punctuation. following code parses date correctly me:

nsstring* strtoconvert = @"7/16/15, 1:08:00 pm eastern daylight time"; nsdateformatter* dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"mm/dd/yy, hh:mm:ss aa zzzz"]; [dateformatter settimezone:[nstimezone timezonewithname:@"est"]]; nslog(@"%@", [dateformatter datefromstring:strtoconvert]); 

Comments