Skip to content

Instantly share code, notes, and snippets.

@azu
Last active October 1, 2021 21:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/5044045 to your computer and use it in GitHub Desktop.
Save azu/5044045 to your computer and use it in GitHub Desktop.
和暦を利用時でも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