当前位置:网站首页>JS calculation time difference
JS calculation time difference
2022-04-23 19:09:00 【GIS roast lamb leg is delicious】
/* Calculate the interval time difference Time type of start time and end time yyyy-MM-dd HH:mm:ss*/
static timeCHA(starttime, endtime) {
var day1 = new Date(starttime);
var day2 = new Date(endtime);
if (starttime && endtime != "") {
// Count the days
var timediff = day2 - day1;
var days = parseInt(timediff / 86400000);
// Calculate hours
var remain = timediff % 86400000;
var hours = parseInt(remain / 3600000);
// Count the minutes
var remain = remain % 3600000;
var mins = parseInt(remain / 60000);
// Calculate seconds
var remain = remain % 60000;
var ss = parseInt(remain / 1000);
var qx = "";
if (days > 0) {
qx += days + " God ";
}
if (hours > 0) {
qx += hours + " when ";
}
if (mins > 0) {
qx += mins + " branch ";
}
if (ss > 0) {
qx += ss + " second ";
}
}
return qx
}
版权声明
本文为[GIS roast lamb leg is delicious]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231908120794.html
边栏推荐
- Openharmony open source developer growth plan, looking for new open source forces that change the world!
- Class loading process of JVM
- ESP32 LVGL8. 1 - calendar (calendar 25)
- openlayers 5.0 热力图
- SQL Server database in clause and exists clause conversion
- [记录]TypeError: this.getOptions is not a function
- 简化路径(力扣71)
- The type initializer for ‘Gdip‘ threw an exception
- Redis optimization series (III) solve common problems after master-slave configuration
- Use of kotlin collaboration in the project
猜你喜欢

12个例子夯实promise基础

Switching power supply design sharing and power supply design skills diagram

I just want to leave a note for myself

从技术体系到商业洞察,中小研发团队架构实践之收尾篇

Esp32 (UART ecoh) - serial port echo worm learning (2)

The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics

SQL常用的命令

From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure

浅谈c语言指针的强制转换

微搭低代码零基础入门课(第三课)
随机推荐
RPM包管理
为何PostgreSQL即将超越SQL Server?
MVVM model
MySQL Téléchargement et installation de la version Linux
Esp32 (UART event) - serial port event learning (1)
FTP, SSH Remote Access and control
Zlib realizes streaming decompression
An 8266 crash
static类变量快速入门
Circuit on-line simulation
Advanced transfer learning
Simplified path (force buckle 71)
SQL server requires to query the information of all employees with surname 'Wang'
c1000k TCP 连接上限测试
【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
Esp32 (UART 485 communication) - 485 communication of serial port (3)
Client interns of a large factory share their experience face to face
Customize the non slidable viewpage and how to use it
Getting started with vcpkg
Switching power supply design sharing and power supply design skills diagram