How to use the addHours function from date-fns

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

76
77
78
79
80
81
82
83
84
85
let startTime = preCheckInValid ? dateFns.addDays(new Date(), 1) : new Date();

if (eligibility === 'INELIGIBLE_TOO_LATE') {
  startTime = dateFns.subHours(startTime, 1);
} else if (eligibility === 'INELIGIBLE_TOO_EARLY') {
  startTime = dateFns.addHours(startTime, 1);
} else if (uuid === aboutToExpireUUID) {
  startTime = dateFns.subMinutes(startTime, 14);
} else {
  startTime = dateFns.addMinutes(startTime, 15);
fork icon124
star icon219
watch icon0

128
129
130
131
132
133
134
135
136
137
case 's':
        return dateTime.addSeconds(date, timeLength);
case 'm':
        return dateTime.addMinutes(date, timeLength);
case 'h':
        return dateTime.addHours(date, timeLength);
case 'd':
        return dateTime.addDays(date, timeLength);
case 'w':
        return dateTime.addWeeks(date, timeLength);
fork icon55
star icon190
watch icon27

21
22
23
24
25
26
27
28
29
30
    return new Date(v)
  }
}

exports.addDaysImpl = dateFns.addDays
exports.addHoursImpl = dateFns.addHours
exports.addISOYearsImpl = dateFns.addISOYears
exports.addMillisecondsImpl = dateFns.addMilliseconds
exports.addMinutesImpl = dateFns.addMinutes
exports.addMonthsImpl = dateFns.addMonths
fork icon0
star icon2
watch icon1

+ 16 other calls in file

59
60
61
62
63
64
65
66
67
68
switch (time.slice(-1)) {
    case 'm':
        remindTime = addMinutes(now, parseInt(time.slice(0, -1)));
        break;
    case 'h':
        remindTime = addHours(now, parseInt(time.slice(0, -1)));
        break;
    case 'd':
        remindTime = addDays(now, parseInt(time.slice(0, -1)));
        break;
fork icon0
star icon0
watch icon0

+ 5 other calls in file

19
20
21
22
23
24
25
26
27
28
temp = dateFns.differenceInDays(y, x);
result = result + temp + ' days ';
x = dateFns.addDays(x, temp);
temp = dateFns.differenceInHours(y, x);
result = result + temp + ' hours ';
x = dateFns.addHours(x, temp);
temp = dateFns.differenceInMinutes(y, x);
result = result + temp + ' minutes ';
x = dateFns.addMinutes(x, temp);
temp = dateFns.differenceInSeconds(y, x);
fork icon0
star icon0
watch icon0

+ 6 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)