Formatting Dates in json

const options = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };

json.forEach(element=> {

let formattedDate =new Date (element.lastUpdated);

element.lastUpdated= formattedDate.toLocaleDateString("en-US",options);

})



https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString


12 views0 comments