I am using below code.
NSString * weekdayString = [[self date] descriptionWithLocale:@"%A"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:usLocale];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
dateString = [NSString stringWithFormat:@"%@,%@",weekdayString,[dateFormatter stringFromDate:[self date]]];
NSArray * components = [dateString componentsSeparatedByString:@","];
dateString = [NSString stringWithFormat:@"%@,%@",[components objectAtIndex:0],[components objectAtIndex:1]];
it’s working fine in simulator and ios 6.0 but it’s not showing as expected in ios 5.1 in device(iPad).
NSDate -descriptionWithLocaleis documented to take anNSLocale; you’re passing anNSStringand therefore relying on undocumented behaviour.It’s also unclear what you’re trying to achieve with the splitting into components — presumably you’ve assumed that the NSDateFormatterShortStyle will always have a comma in it? That also isn’t guaranteed by the documentation.
What you probably want to do is just set a custom date format string. From the title of your post it looks like you probably want
EEEE, MMMM dd. So e.g.QA1480 addresses an issue that can cause
NSDateFormattersilently to adapt your date formatter internally.