cocoa - iPhone: Parse string into a NSDate using NSDateFormatter -


possible duplicate:
converting nsstring nsdate (and again)

i have nsstring representation of date , time such: 6/06/2012 5:55:15 pm

it comes external source , not have ability edit it. if possible wish convert nsdate object using nsdateformatter. tried using code below i'm getting fast, resultant date object null, have idea? i'm guessing i'm leaving important out handle am/pm.

nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"dd/mm/yyyy hh:mm:ss"]; nsdate *currentdate = [formatter datefromstring:job.jobdate];  nslog(@"currentdate = %@",currentdate); // null 

your date string has "pm" in it. format specifier a.

[formatter setdateformat:@"dd/mm/yyyy hh:mm:ss a"]; 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -