// dayjs.ext.ts
import dayjs from 'dayjs';
declare module 'dayjs' {
interface Dayjs {
toISODate(): string;
}
}
const plugin = (_option: any, dayjsClass: any, _dayjsFactory: any) => {
const proto = dayjsClass.prototype;
proto.toISODate = function (): string {
return this.format('YYYY-MM-DD');
};
};
dayjs.extend(plugin);
Import dayjs.ext.ts at main.ts(Angular) to apply.
// main.ts
import './app/utils/dayjs.ext'