On iphone, how can i get the system date in the proper format
Based on local user settings, I want to get the correct date format. For example, it could be any of these:
5 Ja开发者_JS百科n 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)
精彩评论