Skip to content

Instantly share code, notes, and snippets.

@betawax
Created April 14, 2011 08:06
Show Gist options
  • Save betawax/919102 to your computer and use it in GitHub Desktop.
Save betawax/919102 to your computer and use it in GitHub Desktop.
Format a NSDate according to the current locale
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *localizedDateFormat = [NSDateFormatter dateFormatFromTemplate:@"MMMM d, y" options:0 locale:[NSLocale currentLocale]];
[dateFormatter setDateFormat:localizedDateFormat];
NSString *dateString = [dateFormatter stringFromDate:date];
[dateFormatter release];
// dateString will be "April 19, 2010" for US and "19. April 2010" for DE locale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment