Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NgPickDateTime display Military Time

I'm using the ng-pick-datetime picker for my application. I want the selected time to show in 24hr (15:00 instead of 3:00 pm). When the picker opens the time is displayed in the picker correctly, but once selected it changes it to 12hr time format. Is there a way to set the selected time to show in 24 hour time instead of 12 hour?

enter image description here enter image description here

Here is a link to the picker I'm using: ng-pick-datetime

like image 521
Corey Witherow Avatar asked Nov 29 '25 16:11

Corey Witherow


1 Answers

Put hour12: false to custom format, and just working see code below:

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},
  ]
})
like image 85
Temp Avatar answered Dec 02 '25 06:12

Temp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!