How to use the subMinutes function from date-fns

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

78
79
80
81
82
83
84
85
86
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

+ 2 other calls in file

2
3
4
5
6
7
8
9
10
11
12
13
const { DELAY_START_MINS, DELAY_END_MINS } = require('./env.js');


const CST_TIMEZONE_OFFSET = -480;


const getCSTDate = (date) =>
  subMinutes(
    date,
    date.getTimezoneOffset() !== 0
      ? date.getTimezoneOffset()
      : CST_TIMEZONE_OFFSET
fork icon8
star icon5
watch icon0

172
173
174
175
176
177
178
179
180
181
exports.startOfYesterdayImpl = dateFns.startOfYesterday
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
fork icon0
star icon2
watch icon1

+ 16 other calls in file

102
103
104
105
106
107
108
109
110
111
const { ohlc } = req.query;
const queryRealTime = `select time, price from stocks_real_time where symbol = '${req.params.symbol.toUpperCase()}' order by time desc limit 20`
if (ohlc && JSON.parse(ohlc)) {
  const MAX =12
  const timeNow = new Date()
  const upperTime = subMinutes(timeNow, timeNow.getMinutes()%5).valueOf()
  console.log(timeNow.getMinutes()%5)
  let lowerTime = subHours(timeNow, 1).valueOf()
  const queryOhlc = `select bucket AS time, open, high, low, close from ohlc where symbol = '${req.params.symbol.toUpperCase()}' and bucket >= '${new Date(lowerTime).toISOString()}' order by bucket desc limit ${MAX}`
  console.log(queryOhlc)
fork icon0
star icon0
watch icon0

86
87
88
89
90
91
92
93
94
95
96
97
  return null;
};


exports.getRecentAffiliateCodesByDate = async () => {
  try {
    const startDate = subMinutes(GlobalUtils.getUTCDate(), 20).toISOString();
    // console.log('startDate', startDate);


    //With date
    const { data } = await axios.get(
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)