//定义显示日期的格式
NSDateFormatter *dateFormat = [[NSDateFormatter alloc]init];
//NSDateFormatterMediumStyle的显示格式为: Nov 23, 1937” or “3:30:32 PM
dateFormat.dateStyle = NSDateFormatterMediumStyle;
dateFormat.timeStyle = NSDateFormatterMediumStyle; //获取事件选取器的值
NSDate *date = self.datePicker.date;
//将date按dateFormat的格式转换成NSString对象显示并赋给message
NSString *message = [dateFormat stringFromDate:date]; UIAlertController *dateAlert = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *dateAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:nil]; [dateAlert addAction:dateAction]; [self presentViewController:dateAlert animated:YES completion:nil];
04-20 19:13