OwlDateTime,具有24小时格式:
<div *ngIf="isSchedule" class="form-inline">
<label style='margin-right:5px ;margin-left:210px'>
Date Time:
<input [owlDateTimeTrigger]="dt" [owlDateTime]="dt" class="form-control" placeholder="Date time Picker" (change)="getScheduledTime($event)">
<owl-date-time #dt></owl-date-time>
</label>
</div>
答案 0 :(得分:0)
文档:
https://danielykpan.github.io/date-time-picker/#locale-formats
有多种方法可用,但我建议使用moment.js
格式,该格式最灵活。您需要使用此:
npm install ng-pick-datetime-moment moment --save
然后使用以下方法,将用CHANGE THIS标记的属性更改为更合适的moment.js
格式:
import { NgModule } from '@angular/core';
import { OwlDateTimeModule, OWL_DATE_TIME_FORMATS} from 'ng-pick-datetime';
import { OwlMomentDateTimeModule } from 'ng-pick-datetime-moment';
// See the Moment.js docs for the meaning of these formats:
// https://momentjs.com/docs/#/displaying/format/
export const MY_MOMENT_FORMATS = {
parseInput: 'l LT',
fullPickerInput: 'l LT', // CHANGE THIS TO A MOMENT.JS FORMAT
datePickerInput: 'l', // CHANGE THIS TO A MOMENT.JS FORMAT
timePickerInput: 'LT', // CHANGE THIS TO A MOMENT.JS FORMAT
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
};
@NgModule({
imports: [OwlDateTimeModule, OwlMomentDateTimeModule],
providers: [
{provide: OWL_DATE_TIME_FORMATS, useValue: MY_MOMENT_FORMATS},
],
})
export class AppExampleModule {
}
这是moment.js
格式的备忘单: