Files
freeCodeCamp/api/src/utils/validate-donation.ts
2024-07-15 15:23:51 +02:00

11 lines
397 B
TypeScript

/**
* Checks if a timestamp was created within five minutes.
* @param unixTimestamp - A unix timestamp .
* @returns - The generated email template.
*/
export const inLastFiveMinutes = (unixTimestamp: number) => {
const currentTimestamp = Math.floor(Date.now() / 1000);
const timeDifference = currentTimestamp - unixTimestamp;
return timeDifference <= 300; // 300 seconds is 5 minutes
};