// 日期选择器
_picker = [[UIDatePicker alloc] init];
[_picker addTarget:self action:@selector(pickerDidMove:)forControlEvents:UIControlEventValueChanged];
[_picker setLocale:[NSLocale systemLocale]];//设置日期选择器语言--中文,英文
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]
到底使用en_US_POSIX还是en_US, Apple在SDK文档中给出了答案.
In most cases the best locale to choose is “en_US_POSIX”
因为
“en_US_POSIX” is also invariant in time (if the US, at some point in the future, changes the way it formats dates, “en_US” will change to reflect the new behaviour, but “en_US_POSIX” will not), and between machines (“en_US_POSIX” works the same on iPhone OS as it does on Mac OS X, and as it it does on other platforms).
[[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans"]
_picker.maximumDate = [NSDate date];//最大日期是今天
[_picker setDatePickerMode:datePickerMode];//设置模式为日期,时间 或者日期加时间
[_backView addSubview:_picker];
自定义日期选择器见Life365 --AddMuteTimeViewController.m