当前位置:网站首页>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;
}
边栏推荐
- [exercise-1] (UVA 673) parentheses balance/ balanced brackets (stack)
- MySQL import database error [err] 1273 - unknown collation: 'utf8mb4_ 0900_ ai_ ci’
- Problem - 922D、Robot Vacuum Cleaner - Codeforces
- C language learning notes
- Problem - 1646C. Factorials and Powers of Two - Codeforces
- (POJ - 3685) matrix (two sets and two parts)
- [exercise-3] (UVA 442) matrix chain multiplication
- Information security - Epic vulnerability log4j vulnerability mechanism and preventive measures
- Common configuration files of SSM framework
- 图图的学习笔记-进程
猜你喜欢
![[exercise-7] crossover answers](/img/66/3dcba2e70a4cd899fbd78ce4d5bea2.png)
[exercise-7] crossover answers

QT实现窗口渐变消失QPropertyAnimation+进度条

Determine the Photo Position

Luogu P1102 A-B number pair (dichotomy, map, double pointer)

TCP's three handshakes and four waves

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

Configuration du cadre flask loguru log Library

1323. Maximum number of 6 and 9

Vs2019 initial use

“鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
随机推荐
[exercise-7] (UVA 10976) fractions again?! (fraction split)
b站 实时弹幕和历史弹幕 Protobuf 格式解析
Candy delivery (Mathematics)
读取和保存zarr文件
Interval sum ----- discretization
Auto. Getting started with JS
Determine the Photo Position
树莓派4B64位系统安装miniconda(折腾了几天终于解决)
Pytorch extract skeleton (differentiable)
(POJ - 3258) River hopper (two points)
Shell Scripting
Classic application of stack -- bracket matching problem
Programmers, what are your skills in code writing?
Pyside6 signal, slot
渗透测试 ( 1 ) --- 必备 工具、导航
(POJ - 3579) median (two points)
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
AcWing:第56场周赛
Nodejs crawler
Penetration test (1) -- necessary tools, navigation