- 获取当前时间戳
- 当前时间戳+86400获取明天当前时间戳
- 当前时间戳对86400求余得到今天已经过去的时间戳
- 明天当前时间戳 - 今天已经过去的时间戳 + 五个小时的时间戳 = 明天五点的时间戳
/** * 今天现在的时间戳 */ const currentTimestamp = Date.parse(new Date()) / 1000; /** * 今天已经过去的秒数 * UTC时间是从1970年1月1日早晨8点开始的所以对846400求余是获取的当前时间到早晨8点的时间,要获得完整的还得加上8个小时 */ const todayTimestamp = (currentTimestamp % 86400) + 8 * 60 * 60; /** * 明天现在的时间戳 */ const tomorrowTimestamp = currentTimestamp + 86400; /** * 五个小时的时间戳 */ const fiveHourTimestamp = 5 * 60 * 60; /** * 明天五点的时间戳 */ const tomorrow5DotTimestamp = tomorrowTimestamp - todayTimestamp + fiveHourTimestamp;