How to add minutes to a date in Node.js

1 Answer

0 votes
function addMinutesToDate(minutes, date = new Date()) {
  	date.setMinutes(date.getMinutes() + minutes);

  	return date;
}

const date = new Date('2022-03-07T11:18:07');

console.log(addMinutesToDate(56, date).toString());


  
  
  
  
/*
run:
  
Mon Mar 07 2022 12:14:07 GMT+0000 (Coordinated Universal Time)
  
*/

 



answered Mar 21, 2022 by avibootz

Related questions

2 answers 257 views
1 answer 211 views
211 views asked Mar 22, 2022 by avibootz
1 answer 221 views
221 views asked Mar 22, 2022 by avibootz
1 answer 206 views
206 views asked Mar 21, 2022 by avibootz
1 answer 228 views
228 views asked Mar 21, 2022 by avibootz
2 answers 283 views
...