var date = new Date(1663068540); // Date 2011-05-09T06:08:45.178Z
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
console.log(`${year}-${month}-${day}`); // 2011-05-09
Run code snippetHide results
var date = new Date(1663068540); // Date 2011-05-09T06:08:45.178Z
var year = date.getFullYear();
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
console.log(`${year}-${month}-${day}`); // 2011-05-09
Run code snippetHide results