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 264 views
1 answer 217 views
217 views asked Mar 22, 2022 by avibootz
1 answer 228 views
228 views asked Mar 22, 2022 by avibootz
1 answer 215 views
215 views asked Mar 21, 2022 by avibootz
1 answer 237 views
237 views asked Mar 21, 2022 by avibootz
2 answers 289 views
...