I'm receiving from the BE a date value, I need to get the remaining seconds. I am successful, but only if the date is in the current month, if the given date is the next month I'm not sure how to proceed without any library? `
For now I have this working code: `
const convertToSeconds(date: string) {
const startDateTime = new Date();
const endDateTime = new Date(date);
const secondsUntilExpiration = Math.abs(
(startDateTime.getTime() - endDateTime.getTime()) / 1000
);
if (startDateTime > endDateTime) {
return -secondsUntilExpiration;
}
return secondsUntilExpiration;
}