How to use the getDay function from date-fns

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

76
77
78
79
80
81
82
83
84
85
const days = [];

for (let i = 0; i <= totalDays; i += 1) {
  const date = datefns.addDays(startOfYear, i);
  const week = datefns.getWeek(date, { locale });
  const weekday = datefns.getDay(date);
  const day = datefns.format(date, 'd', { locale });

  days.push({
    date,
fork icon28
star icon313
watch icon7

+ 7 other calls in file

53
54
55
56
57
58
59
60
61
62
  const parsed = utcToZonedTime(date, timeZone);
  return getDay(parsed) === 3;
},
'thursday': (date, timeZone) => {
  const parsed = utcToZonedTime(date, timeZone);
  return getDay(parsed) === 4;
},
'friday': (date, timeZone) => {
  const parsed = utcToZonedTime(date, timeZone);
  return getDay(parsed) === 5;
fork icon0
star icon3
watch icon2

+ 13 other calls in file

71
72
73
74
75
76
77
78
79
80
exports.endOfWeekImpl = dateFns.endOfWeek
exports.endOfYearImpl = dateFns.endOfYear
exports.endOfYesterdayImpl = dateFns.endOfYesterday
exports.formatImpl = dateFns.format
exports.getDateImpl = dateFns.getDate
exports.getDayImpl = dateFns.getDay
exports.getDayOfYearImpl = dateFns.getDayOfYear
exports.getDaysInMonthImpl = dateFns.getDaysInMonth
exports.getDaysInYearImpl = dateFns.getDaysInYear
exports.getHoursImpl = dateFns.getHours
fork icon0
star icon2
watch icon1

+ 16 other calls in file

139
140
141
142
143
144
145
146
147
148

function getSpaceInPrevMonth (el) {
        const { year, month } = current_state.opts
        let daysInPrevMonth = getDaysInMonth(new Date(year, month-1))
        // get day in prev month which means to add how many spans
        let dayInPrevMonth = getDay(new Date(year, month-1, daysInPrevMonth))
        for (let s = dayInPrevMonth; s > 0; s--) {
                        let span = document.createElement('div')
                        span.classList.add('day-prev')
                        el.append((span))
fork icon0
star icon0
watch icon2

+ 5 other calls in file

Other functions in date-fns

Sorted by popularity

function icon

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