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 139 views
1 answer 123 views
123 views asked Mar 22, 2022 by avibootz
1 answer 131 views
131 views asked Mar 22, 2022 by avibootz
1 answer 132 views
132 views asked Mar 22, 2022 by avibootz
1 answer 127 views
127 views asked Mar 21, 2022 by avibootz
1 answer 132 views
132 views asked Mar 21, 2022 by avibootz
2 answers 176 views
...