Files
blitzkit/src/core/blitzstars/getTimeDaysAgo.ts
T

12 lines
354 B
TypeScript
Raw Normal View History

2023-06-27 02:16:30 +00:00
export default function getTimeDaysAgo(daysAgo: number) {
2023-06-19 17:35:28 +00:00
const now = new Date();
now.setHours(5, 0, 0, 0);
// if it's after 5:00 AM today, subtract one day
if (now.getTime() > Date.now()) now.setDate(now.getDate() - 1);
// subtract the period number of days from now
2023-06-27 02:16:30 +00:00
now.setDate(now.getDate() - daysAgo);
2023-06-19 17:35:28 +00:00
return now.getTime() / 1000;
}