3

I am using the plugin isToday() to extend the functionality of dayjs() but I don't know how to export isToday() so I can use it in other files.

import isToday from "dayjs/plugin/isToday";

export dayjs.extend(isToday);

1 Answers1

1

You can export it as follows:

import dayjs from 'dayjs';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import 'dayjs/locale/en';

dayjs.extend(isSameOrBefore);
dayjs.extend(isSameOrAfter);

export { dayjs }; // OR export default dayjs

If you are using TypeScript and you want a Dayjs similar type, you can use:

// ...

const dayjsInstance = dayjs();
export type Dayjs = typeof dayjsInstance;