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

Delphi change the assembly code of a running process -

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

C++ 11 "class" keyword -