I am looking to transfer all data from one array to another in TypeScript based on a certain condition.
array: any =
[
{
Hostname: 'CBA',
Certificate_Expiry_Date: 'Thu Mar 25 16:32:48 GMT 2021',
'': ''
},
{
Hostname: 'CBCB',
Certificate_Expiry_Date: 'Wed Apr 07 11:19:01 IST 2021',
'': ''
},
{
Hostname: 'cbcb',
Certificate_Expiry_Date: 'Thu Apr 01 12:05:22 IST 2021',
'': ''
},
{
Hostname: 'cbm',
Certificate_Expiry_Date: 'Sat Apr 04 10:45:19 IST 2020',
];
alert() {
if (this.array.Certificate_Expiry_Date > Date) {
this.array.forEach(item => {
this.alertsArray.push(
item.Hostname,
item.Certificate_Expiry_Date
);
});
}
console.log(this.alertsArray);
}
I need help modifying the above code to add an object to the alerts array when the certificate expiration date is less than two months away, as my current implementation does not seem to be working as expected. Any assistance would be greatly appreciated.