如何以角度的方式从OwlDateTime中删除AM和PM(因为它已经采用24小时格式)

时间:2018-10-09 09:10:25

标签: angular typescript

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>

1 个答案:

答案 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格式的备忘单:

https://devhints.io/moment