I have an application, where I use MongoDB, Express and MongoDB. On server side I received data by using find in such look – array of objects(JSON), which is named upProbations. For example, I find information about Max:
[
{
Name: 'Max',
DateOne: 2019-01-01T00:00:00.000Z,
DateTwo: 2019-04-01T00:00:00.000Z,
Info: 'Cheerful'
}
]
I want to change information a bit – fields DateOne and DateTwo. They have both types Date and I want to leave only 2019-01-01 and same for DateTwo, so i don’t need time(hour, minute, second). The result should look like this:
[
{
Name: 'Peter',
DateOne: 2019-01-01,
DateTwo: 2019-04-01,
Info: 'Cheerful'
}
]
This result I will futher use for antoher calculations. I have tried such code, but it’s not working:
upProbations = upProbations.map(function(a) {
a.startProb = a.startProb.toISOString().replace('T', ' ').substr(0, 10);
return a;
})
console.log(upProbations);
In which way I can do this?