Created
April 14, 2011 08:06
-
-
Save betawax/919102 to your computer and use it in GitHub Desktop.
Format a NSDate according to the current locale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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