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



OwlDateTime with 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>

文档:

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

相关内容

最新更新