I'm writing a js code that takes in a JSON of string arrays, that also has dates formatted as strings in it. Below is a sample code of the same.
var prods = [
{
"id": "56e535de-319f-4612-be83-3084a060b77e",
"createdDate": "2021-04-28T11:34:54.975",
"modifiedDate": "2021-04-28T11:34:54.976"
},
{
"id": "55753a5d-377d-4038-baf0-5ecbf620601a",
"createdDate": "2021-04-27T16:22:02.621",
"modifiedDate": "2021-04-27T16:22:02.621"
},
{
"id": "e9593d91-d884-40e8-8239-5f69794f2b3a",
"createdDate": "2021-04-27T15:29:55.737",
"modifiedDate": "2021-04-27T15:29:55.737"
}
];
prods = prods.map(function(a) {
a.createdDate = Date.parse(a.createdDate);
return a;
});
console.log(prods)
Here I'm able to convert for createdDate
. I want to know how I can do for both createdDate
as well as modifiedDate
by looping over the JSON.
Thanks