views:

43

answers:

2

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.

+2  A: 

Use NSDateFormatter with one of the NSDateFormatterStyle styles. It automatically uses the user's locale.

Ole Begemann
+1  A: 

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)

BK
Thanks. close but this does not use the current user locale though.
glutz78