top of page

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


14 views0 comments
bottom of page