当前位置:网站首页>计算时间差
计算时间差
2022-07-06 09:28:00 【梦想身高1米8】
// deadline:string 截止日期
// 计算当前之间到截止日期还有多久
// return:string x天x小时x分x秒
const computeRemainTime = deadlineTime => {
let r = '';
// 截止日期和当前时间之间相差多少毫秒
let seconds = new Date(deadlineTime).getTime() - new Date().getTime();
// 相差天数
const day = Math.floor(seconds / (24 * 3600 * 1000));
r += day ? day + '天' : '';
// 去掉天数的毫秒数
seconds = seconds % (24 * 3600 * 1000);
// 还剩几个小时
const hour = Math.floor(seconds / (3600 * 1000));
r += hour ? hour + '小时' : '';
// 去掉小时的毫秒数
seconds = seconds % (3600 * 1000);
// 还剩几分钟
const minute = Math.floor(seconds / (60 * 1000));
r += minute ? minute + '分' : '';
// 还剩几秒钟
seconds = seconds % (60 * 1000);
// 去掉分钟的毫秒数
const second = Math.round(seconds / 1000);
r += second ? second + '秒' : '';
return r;
}
边栏推荐
- Opencv learning log 29 -- gamma correction
- Sanic异步框架真的这么强吗?实践中找真理
- 1855. Maximum distance of subscript alignment
- TCP's three handshakes and four waves
- Frida hook so layer, protobuf data analysis
- 渗透测试 ( 1 ) --- 必备 工具、导航
- [exercise-8] (UVA 246) 10-20-30== simulation
- Write web games in C language
- QNetworkAccessManager实现ftp功能总结
- E. Breaking the Wall
猜你喜欢
![[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class](/img/57/bc6eda91f7263acda38b9ee8732318.png)
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class

921. Minimum additions to make parentheses valid

Radar equipment (greedy)

Maximum product (greedy)
![[exercise-7] crossover answers](/img/66/3dcba2e70a4cd899fbd78ce4d5bea2.png)
[exercise-7] crossover answers

Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack

Configuration du cadre flask loguru log Library

Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools

Pyside6 signal, slot

Openwrt build Hello ipk
随机推荐
Some problems encountered in installing pytorch in windows11 CONDA
1005. Maximized array sum after K negations
Penetration test (2) -- penetration test system, target, GoogleHacking, Kali tool
Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
C language must memorize code Encyclopedia
Penetration test (1) -- necessary tools, navigation
628. Maximum product of three numbers
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
HDU - 6024 building shops (girls' competition)
【练习4-1】Cake Distribution(分配蛋糕)
Gartner: five suggestions on best practices for zero trust network access
Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack
【练习-5】(Uva 839)Not so Mobile(天平)
最全编程语言在线 API 文档
[exercise -11] 4 values why sum is 0 (and 4 values of 0)
2027. Minimum number of operations to convert strings
Penetration test (8) -- official document of burp Suite Pro
Determine the Photo Position
Pytorch extract skeleton (differentiable)
window11 conda安装pytorch过程中遇到的一些问题