Date from String


/ Published in: Objective C



Copy this code and paste it in your HTML
  1. NSString *dateStr = @"20100223";
  2.  
  3. // Convert string to date object
  4. NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
  5. [dateFormat setDateFormat:@"yyyyMMdd"];
  6. NSDate *date = [dateFormat dateFromString:dateStr];
  7.  
  8. // Convert date object to desired output format
  9. [dateFormat setDateFormat:@"EEEE MMMM d, YYYY"];
  10. dateStr = [dateFormat stringFromDate:date];
  11. [dateFormat release];

URL: http://stackoverflow.com/questions/2311421/convert-string-to-nsdate

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.