2011-11-22 51 views

Trả lời

1

Xem lớp NSDateFormatter http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html

Cái gì như:

NSDate *date = [NSDate date]; 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 

[dateFormatter setDateStyle:NSDateFormatterNoStyle]; 
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; 
[dateFormatter setLocale:[NSLocale currentLocale]]; 

NSString *dateString = [dateFormatter stringFromDate:date]; 
0

Bạn thường không cần phải tìm ra những gì cài đặt ngôn ngữ của người dùng được khi hiển thị dữ liệu cho người dùng. Nếu bạn sử dụng NSFormatter (NSNumberFormatter có liên quan cho số và NSDateFormatter cho ngày và giờ, số này phù hợp với bạn trong trường hợp này), thì bạn sẽ tự động nhận được kết quả phù hợp với ngôn ngữ của người dùng ... "localized representation of the object"

Các vấn đề liên quan