iphone - Convert NSString of a date to an NSDate -
this might silly question, can't seem find answer on here or in documentation.
i want convert nsstring such @"9/22/2010 3:45 pm" nsdate.
i know use nsdateformatter, problems
- the month 1 or 2 digits
- likewise, date 1 or 2 digits
- hours 1 or 2 digits
- what do am/pm?
nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"mm/dd/yyyy h:mm a"]; nsdate *date = [dateformat datefromstring:datestr]; [dateformat release];
there no problem in 2 digit day or 2 digit month.
this must you.
Comments
Post a Comment