I have a task of formatting dates within an array. I attempted to achieve this by running a forEach loop and using moment format, but unfortunately the results turned out to be invalid.
response = [
{
"type": "blackout",
"dates": ["2019-12-31T17:52:30.263Z", "2020-11-21T17:52:30.263Z", "2020-11-22T17:52:30:263Z"],
"description": "Blackout Period"
}..........................................................................................]
response.forEach( items => {
const dates = moment(items.dates).format('YYYYMMDD');
console.log(dates, "dkjedjedkjed");
});
Here is the link to StackBlitz. I tried one solution but encountered some issues with certain dates appearing as invalid. https://stackblitz.com/edit/angular-hxmkkd