当前位置:网站首页>计算时间差
计算时间差
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;
}
边栏推荐
- pytorch提取骨架(可微)
- [exercise-8] (UVA 246) 10-20-30== simulation
- 【练习-6】(PTA)分而治之
- Candy delivery (Mathematics)
- Basic Q & A of introductory C language
- Information security - threat detection engine - common rule engine base performance comparison
- (POJ - 3685) matrix (two sets and two parts)
- 7-1 understand everything (20 points)
- Opencv learning log 29 -- gamma correction
- 1013. Divide the array into three parts equal to and
猜你喜欢
【练习-5】(Uva 839)Not so Mobile(天平)
921. Minimum additions to make parentheses valid
C language is the watershed between low-level and high-level
X-forwarded-for details, how to get the client IP
Penetration test (1) -- necessary tools, navigation
1903. Maximum odd number in string
Advancedinstaller安装包自定义操作打开文件
807. Maintain the urban skyline
b站 实时弹幕和历史弹幕 Protobuf 格式解析
b站 實時彈幕和曆史彈幕 Protobuf 格式解析
随机推荐
[exercise-2] (UVA 712) s-trees
Data storage in memory & loading into memory to make the program run
(POJ - 2739) sum of constructive prime numbers (ruler or two points)
(POJ - 3258) River hopper (two points)
Gartner:关于零信任网络访问最佳实践的五个建议
Luogu P1102 A-B number pair (dichotomy, map, double pointer)
双向链表—全部操作
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Information security - threat detection engine - common rule engine base performance comparison
The "sneaky" new asteroid will pass the earth safely this week: how to watch it
Interesting drink
【练习-7】(Uva 10976)Fractions Again?!(分数拆分)
Find 3-friendly Integers
C language must memorize code Encyclopedia
QWidget代码设置样式表探讨
628. Maximum product of three numbers
Read and save zarr files
D - function (HDU - 6546) girls' competition
B - Code Party (girls' competition)
Nodejs+vue online fresh flower shop sales information system express+mysql