2 yue1liang1chuan yue1liang1chuan 于 2013.02.25 10:45 提问

UIDatePicker显示星期日

我希望从UIDatePicker中选择日期后,显示成下面的日期格式,应该怎么实现呢?

日期格式: Sat Feb 23 3:42 PM

2个回答

xinyoulingxi1_tong
xinyoulingxi1_tong   2013.02.25 11:07
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];
vikeyToy
vikeyToy   2013.02.25 11:36
NSDateFomatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormat:@"DDD MMM dd mm:ss aa"];
NSString *dateString = [dateFormatter stringFromDate:date];
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!