Skip to content

Instantly share code, notes, and snippets.

@azu
Last active Oct 1, 2021
Embed
What would you like to do?
和暦を利用時でもUIDatePickerでカレンダー:西暦の表示にする
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
// 言語は日本語(iOSの設定の書式に該当)
datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"ja_JP"];
// カレンダーは西暦(iOSの設定のカレンダーに該当)
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
gregorian.locale = [NSLocale currentLocale];
datePicker.calendar = gregorian;
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment