Home > other >  Date shows one day before from selected date in angular
Date shows one day before from selected date in angular

Time:12-21

Date showing one date before from selected date how to fix it?

My code sample is

let ds = this.prdate.formfileds[0].var;

let mv = moment(ds,'MM-DD-YYYY');

let stv = mv.format('YYYY-MM-DD');

CodePudding user response:

Try the below code.

let date = new Date();
console.log('NATIVE JS DATE TIME', date.toString());
console.log('STRINGIFIED TIME', JSON.stringify(date));
console.log('FORMATTED TIME', `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`);

  • Related