返回 AiToEarn
time.util.ts
根目录 / project / aitoearn-electron / server / src / util / time.util.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-07-22 17:57:25
4 * @LastEditTime: 2024-07-22 17:59:08
5 * @LastEditors: nevin
6 * @Description:
7 */
8 // 获取今天的0点(午夜)时间
9 export function getTodayMidnight(): Date {
10 const todayMidnight = new Date();
11 todayMidnight.setHours(0, 0, 0, 0);
12
13 return todayMidnight;
14 }
15
16 // 获取今天的24点(实际上是明天的0点)
17 export function getTodayEnd(): Date {
18 const todayEnd = new Date();
19 todayEnd.setDate(todayEnd.getDate() + 1);
20 todayEnd.setHours(0, 0, 0, 0);
21 return todayEnd;
22 }
23
24 // 获取当前的秒级时间戳
25 export function getCurrentTimestamp(): number {
26 return Math.floor(new Date().getTime() / 1000);
27 }
28
28 lines TYPESCRIPT