NSDate in full style but without year

I know this is a pretty old question but this is the only one I found on SO that talked about the same issue I was having.

The key method to use here is: dateFormatFromTemplate

Instead of setting the style, you want to set the format as such:

NSDate *testdate = [NSDate date];

NSLocale *currentLocale = [NSLocale currentLocale];

// Set the date components you want
NSString *dateComponents = @"EEEEMMMMd";

// The components will be reordered according to the locale
NSString *dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:currentLocale];
NSLog(@"Date format for %@: %@", [currentLocale displayNameForKey:NSLocaleIdentifier value:[currentLocale localeIdentifier]], dateFormat);

NSDateFormatter *dateFormatter =[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:dateFormat];

NSString *formattedDateString = [dateFormatter stringFromDate:testdate];
NSLog(formattedDateString);

Special thanks to: http://oleb.net/blog/2011/11/working-with-date-and-time-in-cocoa-part-2/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)