ios7 - Parse string as date contains words -
ios7 - Parse string as date contains words -
i want parse "date: 12-9-2014 time: 20-13-59" string nsdate. have tried parsing using format
nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"date: dd-mm-yyyy time: hh-mm-ss"]; nsdate *date = [dateformatter datefromstring:timestamp]; nslog(@"asd: %@", date);
it returns null. doing wrong, please advice.
thanks
add quotes around parts of date string literal, , not formatting characters:
[dateformatter setdateformat:@"'date:' dd-mm-yyyy 'time:' hh-mm-ss"];
ios7 nsdateformatter
Comments
Post a Comment