How to use the subMonths function from date-fns

Find comprehensive JavaScript date-fns.subMonths code examples handpicked from public code repositorys.

173
174
175
176
177
178
179
180
181
182
exports.subDaysImpl = dateFns.subDays
exports.subHoursImpl = dateFns.subHours
exports.subISOYearsImpl = dateFns.subISOYears
exports.subMillisecondsImpl = dateFns.subMilliseconds
exports.subMinutesImpl = dateFns.subMinutes
exports.subMonthsImpl = dateFns.subMonths
exports.subQuartersImpl = dateFns.subQuarters
exports.subSecondsImpl = dateFns.subSeconds
exports.subWeeksImpl = dateFns.subWeeks
exports.subYearsImpl = dateFns.subYears
fork icon0
star icon2
watch icon1

+ 16 other calls in file

465
466
467
468
469
470
471
472
473
474
    (dateFns.isSameMonth(props.lowerLimit, props.pageDate) ||
        dateFns.isBefore(props.pageDate, props.lowerLimit)));
const rightDisabled = vue.computed(() => props.upperLimit &&
    (dateFns.isSameMonth(props.upperLimit, props.pageDate) ||
        dateFns.isAfter(props.pageDate, props.upperLimit)));
const previousPage = () => emit('update:pageDate', dateFns.subMonths(props.pageDate, 1));
const nextPage = () => emit('update:pageDate', dateFns.addMonths(props.pageDate, 1));
return {
    weekDays,
    days,
fork icon0
star icon0
watch icon0

+ 9 other calls in file

21
22
23
24
25
26
27
28
29
30
userTimeZone,
// Get a date with an offset
lastMilliseconds: (milliseconds) => subMilliseconds(currentDate, milliseconds),
lastHours: (hours) => subHours(currentDate, hours),
lastDays: (days) => subDays(currentDate, days),
lastMonths: (months) => subMonths(currentDate, months),
lastYears: (years) => subYears(currentDate, years),
// Get a date with an offset that always includes the whole unit of the given interval and a timezone toleranz
includeDays: (days) => subHours(subDays(startOfDay(currentDate), days - 1), timeZoneToleranz),
includeMonths: (months) => subHours(subMonths(startOfMonth(currentDate), months - 1), timeZoneToleranz),
fork icon0
star icon0
watch icon0

74
75
76
77
78
79
80
81
82
83
  endDate = new Date();
  startDate = subDays(new Date(),7);
}
else if(reportUser[0].reporttype === "Monthly"){
  endDate = new Date();
  startDate = subMonths(new Date(),1);
}
else if(reportUser[0].reporttype === "Quarterly"){
  endDate = new Date();
  startDate = subQuarters(new Date(),1);
fork icon0
star icon0
watch icon0

Other functions in date-fns

Sorted by popularity

function icon

date-fns.format is the most popular function in date-fns (3838 examples)