sajad torkamani
function dateToUnixTimestamp(date: Date): number {
  return Math.floor(date.getTime() / 1000);
}

// Example usage
const myDate = new Date(); // Create a Date instance for the current time
const unixTimestamp = dateToUnixTimestamp(myDate);

console.log(unixTimestamp); // Outputs the UNIX timestamp for `myDate`
Tagged: