2013-02-23 109 views

回答

2

這裏是你的願望輸出代碼: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns

NSDate *chosen = [datePicker date]; 

NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 
[formatter setDateFormat:@"EEE MMM dd hh:mm a"]; 

NSString *formated_date = [formatter stringFromDate:chosen]; 

NSLog(@"formated date is : %@", formated_date]; 

您可以通過閱讀此鏈接更改日期的格式

1
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 
NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit ; 
NSDateComponents *components = [gregorian components:unitFlags fromDate:yourPickerDate]; 
NSInteger yourWeekDay = [components weekday]; 

我認爲這將是對你有所幫助。

1
NSDateFomatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setFormat:@"DDD MMM dd mm:ss aa"]; 
NSString *dateString = [dateFormatter stringFromDate:date]; 
0

我得到它....

NSDateFormatter * DATEFORMAT = [[NSDateFormatter的alloc] INIT];

[dateFormat setDateFormat:@「EEE MMM dd hh:mm aa」]; NSLog(@「format is:%@」,[dateFormat stringFromDate:datePicker.date]);