javascript - 倒计时不超过两个日期
问题描述
需要帮助来自定义此脚本
<script>
jQuery(document).ready(function($){
$('.demo4').dsCountDown({
startDate: new Date("December 11, 2020 12:12:29"),
endDate: new Date("December 12, 2020 12:12:29"),
theme: '',
titleDays: 'd',
titleHours: 'h',
titleMinutes: 'm',
titleSeconds: 's'
,onFinish: function(){
$.ajax({
type: 'GET',
url: 'get_update.php'
});
setTimeout(function(){
window.location = "index.php?go=stake";
}, 3000);
}
});
});
</script>
如何将这两个日期之间的时间更改为单个值
startDate: new Date("December 11, 2020 12:12:29"),
endDate: new Date("December 11, 2020 12:17:29"),
我想要单个值等 5 分钟不在两个日期之间,例如 startdate - enddate
解决方案
var diffMs = (startDate - endDate);
var diffDays = Math.floor(diffMs / 86400000); // days
var diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hours
var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
console.log(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes)");
推荐阅读
- python - Python - 列表返回 [[...], 6]
- mysql - 插入 SQL 之前的 Pb TRIGGER
- python - pigpio 守护进程处于非活动状态,即使连接仍然存在
- scala - Spark Job 由于阶段失败而中止:使用 spark-xml 加载 xml 文件时出现 java.lang.NullPointerException
- java - 带有arm处理器的debian linux上的android-sdk
- javascript - 为什么带有 src="../node_modules/angular/angular.js" 的脚本标签不起作用?
- windows - 如何使用 CreateFile("\\\\.\\LCD") 打开所有连接的 LCD 显示器的句柄?
- android - 通过片段打开地图时出现问题
- reactjs - 如何在托管站点上自动运行 React 应用程序和 Express 服务器
- regex - 如何删除包含 csv 数据的 RDD 中包含空值的条目?