How to remove seconds and milliseconds from a date in JavaScript

1 Answer

0 votes
const date = new Date('2022-03-20T12:03:27.724Z');

date.setSeconds(0, 0);

console.log(date.toISOString()); 

  
  
  
/*
run:
  
"2022-03-20T12:03:00.000Z"
  
*/

 



answered Mar 20, 2022 by avibootz
...