我正在为我的应用程序使用 ng-pick-datetime 选择器。我希望选定的时间在 24 小时内显示(15:00 而不是下午 3:00)。 When the picker opens the time is displayed in the picker correctly, but once selected it changes it to 12hr time format.有没有办法将所选时间设置为以 24 小时制而不是 12 小时制显示?
这是我正在使用的选择器的链接: ng-pick-datetime
最佳答案
将 hour12: false 设置为自定义格式,即可正常工作,请参见下面的代码:
export const MY_NATIVE_FORMATS = {
fullPickerInput: {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', hour12: false},
datePickerInput: {year: 'numeric', month: 'numeric', day: 'numeric', hour12: false},
timePickerInput: {hour: 'numeric', minute: 'numeric', hour12: false},
monthYearLabel: {year: 'numeric', month: 'short'},
dateA11yLabel: {year: 'numeric', month: 'long', day: 'numeric'},
monthYearA11yLabel: {year: 'numeric', month: 'long'},
};
@NgModule({
providers: [
{provide: OWL_DATE_TIME_FORMATS, useValue: MY_NATIVE_FORMATS},
]
})
关于datetimepicker - NgPickDateTime 显示军用时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49242640/