function secondsUtil(isoDate: string | Date): number | null {
  try {
    const targetDate = new Date(isoDate);
    const currentDate = new Date();
    const differenceInMilliseconds =
      targetDate.getTime() - currentDate.getTime();

    if (Number.isNaN(differenceInMilliseconds)) {
      console.error("Invalid date provided");
      return null;
    }

    return Math.round(differenceInMilliseconds / 1000);
  } catch (error) {
    console.error("An error occurred:", error);
    return null;
  }
}

export default secondsUtil;
