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

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -