I\'m passing \"2018-01-31T22:55:02.907Z\" this timestamp to the moment() function but it returns the wrong value after formatting the date part.
You have to use moment.utc():
By default, moment parses and displays in local time.
If you want to parse or display a moment in UTC, you can use
moment.utc()instead ofmoment().
console.log(moment("2018-01-31T22:55:02.907Z").format('YYYY-MM-DD'));
console.log(moment.utc("2018-01-31T22:55:02.907Z").format('YYYY-MM-DD'));