Based on local user settings, I want to get the correct date format. For example, it could be any of these:
5 Jan 2010 January 5, 2010 1/5/10
And how about on windows?
Thanks.
Based on local user settings, I want to get the correct date format. For example, it could be any of these:
5 Jan 2010 January 5, 2010 1/5/10
And how about on windows?
Thanks.
Use NSDateFormatter
with one of the NSDateFormatterStyle
styles. It automatically uses the user's locale.
NSDate *selected = [NSDate date];
NSDateFormatter *format = [[[NSDateFormatter alloc] init] autorelease];
[format setDateFormat:@"MM/dd/YYYY"];
strDate = [format stringFromDate:selected];
Change the format to any thing u want.(M for month, d for day, Y for year, m for minute, h for hour and s for sec)