nsdate - A problem when converting string to date in iPhone? -


How to change NSString from 2010-08-03 04: 37: 31: 31.0 to 3 August 2010?

Is this possible?

This is probably a duplicate but NSDateFormatter is what you are looking for Are there.

NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [DateFormatter setDateFormat: @ "yyyy-MM-dd HH: mm: SS"]; NSDate * date = [dateFormatter dateFromString: inDateString]; [DateFormatter setDateFormat: @ "MMMM DD ',' Yay ']; NSString * Outdated String = [dateFormatter stringFromDate: date];

Although there are two problems with this approach.

  1. The input string is that it does not have timezone data
  2. Unlike different cultures, different orders from the day of the month if you use the normal NSDateFormatterStyle formats such as NSDateFormatterLongStyle can use one of .
,

Comments