开发者

On iphone, how can i get the system date in the proper format

开发者 https://www.devze.com 2022-12-18 12:13 出处:网络
Based on local user settings, I want to get the correct date format. For example, it could be any of these:

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号