2010-11-22 119 views

回答

6

使用NSDateFormatter

喜欢的东西:

NSDate *date=//...; 
; 
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setTimeStyle:NSDateFormatterNoStyle]; 
[dateFormatter setDateStyle:NSDateFormatterLongStyle]; 
NSString *string=[dateFormatter stringFromDate:date]; 
//.... 
NSDate *newDate=[dateFormatter dateFromString:string]; 

还有更多的细节我不覆盖,如语言环境的问题和诸如此类的东西,但是这应该让你去