Resources:
There are multiple methods you can choose from, but I highly recommend utilizing the moment.js
format for its flexibility. To implement this, follow these steps:
npm install ng-pick-datetime-moment moment --save
Then proceed with the following approach, modifying the properties marked as CHANGE THIS to match a suitable moment.js
format:
import { NgModule } from '@angular/core';
import { OwlDateTimeModule, OWL_DATE_TIME_FORMATS} from 'ng-pick-datetime';
import { OwlMomentDateTimeModule } from 'ng-pick-datetime-moment';
// Refer to Moment.js documentation for details on 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 {
}
For a helpful guide on moment.js
formatting, refer to the cheatsheet here: