Home > Mobile >  How can get current date as 2021-12-30T18:30:00.000z this format in angular
How can get current date as 2021-12-30T18:30:00.000z this format in angular

Time:12-31

I have tried like var str=new Date(); var dt= new Date(str).toISOString(); console.log(dt); but it's shows 2021-12-30T18:30:00.000z. please can anyone help me to solve this.thanks in advance.

CodePudding user response:

If you were going for a string with no seconds and milliseconds, use setSeconds on Date:

var str = new Date().setSeconds(0,0);
var dt = new Date(str).toISOString(); 
console.log(dt);
  • Related