javascript - 如何做这个语句的计算
问题描述
怎么做这个语句的计算
var dateTo = new Date(2019,04,03,3,15,0);
var countdown = Math.round((dateTo.getTime() - new Date().getTime()) / 1000);
解决方案
这就是你想要的吗?
#// Set the date we're counting down to
var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
console.warn("val", days);
推荐阅读
- mysql - 导入 xlrd、MySQL 等包时出现回溯错误
- odbc - 如何在 OpenRefine 中使用 Oracle ODBC 连接?
- javascript - 通过 SetValue() 方法在 Monaco Editor 中设置正则表达式
- html - 地址未正确对齐
- python - 列不匹配雪花,第 1 行从第 2 行开始,列 ""table_name""["Account":1]
- javascript - 将内容从一个对象复制到另一个对象时,按键名排除特定键/值对
- geometry - 如何计算射线和点云的交点?
- java - Morphia:接受单个值作为数组,用于 morphia 实体中的字段
- karate - 空手道测试成功运行,但代码覆盖率显示为零
- ios - Xamarin iOS 发布自动预配 - 没有货币安装的预配配置文件