mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
13 lines
354 B
TypeScript
13 lines
354 B
TypeScript
export default function getTimeDaysAgo(daysAgo: number) {
|
|
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
|
|
now.setDate(now.getDate() - daysAgo);
|
|
|
|
return now.getTime() / 1000;
|
|
}
|