datetimepicker - NgPickDateTime 显示军用时间

标签 datetimepicker angular5

我正在为我的应用程序使用 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 小时制显示?

enter image description here enter image description here

这是我正在使用的选择器的链接: 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/

相关文章:

javascript - 使用 Angular 5 发送自定义 header

asp.net-core - 带有 Angular 5 的 ASP.NET Core -- 何时使用 Assets 文件夹与 wwwroot 文件夹?

java - 如何在 Angular 5中未经授权使用主页中的实体数据

javascript - 链接的日期时间选择器不应允许某些日期

javascript - jQuery datetimepicker 插件范围错误

c# - 使用日期时间选择器过滤 Crystal 报表中的数据

xcode timePicker 返回错误的时间

javascript - 为什么 Firefox 不遵守标准的 javascript 支持元素测试

Angular 5 模板驱动的十进制输入

Angular Material 分页器不工作