当前位置:网站首页>Calculate the time difference
Calculate the time difference
2022-07-06 16:14:00 【Dream height 1.8 meters】
// deadline:string Closing date
// Calculate how long it will be between now and the deadline
// return:string x God x Hours x branch x second
const computeRemainTime = deadlineTime => {
let r = '';
// How many milliseconds is the difference between the deadline and the current time
let seconds = new Date(deadlineTime).getTime() - new Date().getTime();
// return int
const day = Math.floor(seconds / (24 * 3600 * 1000));
r += day ? day + ' God ' : '';
// Remove the milliseconds of the number of days
seconds = seconds % (24 * 3600 * 1000);
// A few hours left
const hour = Math.floor(seconds / (3600 * 1000));
r += hour ? hour + ' Hours ' : '';
// Remove the milliseconds of the hour
seconds = seconds % (3600 * 1000);
// A few minutes left
const minute = Math.floor(seconds / (60 * 1000));
r += minute ? minute + ' branch ' : '';
// A few seconds left
seconds = seconds % (60 * 1000);
// Remove the milliseconds in minutes
const second = Math.round(seconds / 1000);
r += second ? second + ' second ' : '';
return r;
}
边栏推荐
- 树莓派4B64位系统安装miniconda(折腾了几天终于解决)
- Raspberry pie csi/usb camera uses mjpg to realize web camera monitoring
- F - birthday cake (Shandong race)
- Penetration test (8) -- official document of burp Suite Pro
- 1903. Maximum odd number in string
- Pytorch extract skeleton (differentiable)
- QT实现窗口置顶、置顶状态切换、多窗口置顶优先关系
- 860. Lemonade change
- Basic Q & A of introductory C language
- [exercise-2] (UVA 712) s-trees
猜你喜欢
969. Pancake sorting
浏览器打印边距,默认/无边距,占满1页A4
1005. Maximized array sum after K negations
渗透测试 ( 2 ) --- 渗透测试系统、靶机、GoogleHacking、kali工具
Suffix expression (greed + thinking)
Penetration testing (5) -- a collection of practical skills of scanning King nmap and penetration testing tools
QT实现窗口渐变消失QPropertyAnimation+进度条
Read and save zarr files
[exercise-7] crossover answers
628. Maximum product of three numbers
随机推荐
1903. Maximum odd number in string
Share an example of running dash application in raspberry pie.
Suffix expression (greed + thinking)
[exercise-3] (UVA 442) matrix chain multiplication
读取和保存zarr文件
Educational Codeforces Round 130 (Rated for Div. 2)A~C
antd upload beforeUpload中禁止触发onchange
Openwrt source code generation image
日期加1天
QT有关QCobobox控件的样式设置(圆角、下拉框,向上展开、可编辑、内部布局等)
Alice and Bob (2021 Niuke summer multi school training camp 1)
树莓派CSI/USB摄像头使用mjpg实现网页摄像头监控
Penetration test (1) -- necessary tools, navigation
Quick to typescript Guide
第 300 场周赛 - 力扣(LeetCode)
[exercise-2] (UVA 712) s-trees
If you want to apply for a programmer, your resume should be written like this [essence summary]
[exercise-5] (UVA 839) not so mobile (balance)
[exercise-6] (UVA 725) division = = violence
Basic Q & A of introductory C language