I am working on a function that will iterate through an array of objects with the type any[]
, specifically looking at the ExpiryDate
property to determine if the passport is still valid. If the ExpiryDate
is greater than the current date and time, then the passport is considered valid; otherwise, it has expired.
currentPassports: any[];
oldPassports: any[];
passports: any[];
processPassports(passports: any[]): void {
var arrayLength = passports.length;
for (var i = 0; i < arrayLength; i++) {
if (passports[i].ExpiryDate > CurrentDateTime)
// Add the object to currentPassports
else
// Add the object to expiredPassports
}
}
I'm seeking advice on how to best compare SQL datetime values to the current time in TypeScript. Furthermore, I need assistance in ensuring that each object's ExpiryDate
property is compared exactly down to the milliseconds.
Please note that CurrentDateTime
is currently just being used as a placeholder.