Where do I put global day.js configuration in a React project so that it applies everywhere?

Advertisements I want to do the following day.js configuration: import dayjs from ‘dayjs’; // add plugins for timezone functionality import utc from ‘dayjs/plugin/utc’; import timezone from ‘dayjs/plugin/timezone’; dayjs.extend(utc); dayjs.extend(timezone); // set default timezone dayjs.tz.setDefault("America/New_York"); // set default format (source: https://stackoverflow.com/a/77459776/22134371) dayjs.extend((option, dayjsClass, dayjsFactory) => { const oldFormat = dayjsClass.prototype.format; dayjsClass.prototype.format = function (formatString) { return… Read More Where do I put global day.js configuration in a React project so that it applies everywhere?

dayjs: date supplied from mongodb is at least 5 minutes old

Advertisements I’m using dayjs and trying to figure out how to check if a date is at least 5 minutes ago. Here is an example of a date: 2021-11-04T12:20:46.485Z Its probably some subtracting and adding 5 somewhere but the MongoDB format and dayjs is somewhat confusing. Ref ? https://day.js.org/docs/en/query/is-after >Solution : Check this out: Using… Read More dayjs: date supplied from mongodb is at least 5 minutes old