当前位置:网站首页>JS Date 时间戳 getTune data.parse 倒计时小程序
JS Date 时间戳 getTune data.parse 倒计时小程序
2022-08-02 21:33:00 【HandsomeDanielWu】








时间戳 getTune data.parse分析




倒计时小程序
<body>
<h1>2021年高考倒计时</h1>
<h2 id="info"></h2>
<script>
var info = document.getElementById('info');
setInterval(function(){
// 现在的日期
var nd = new Date();//Tue Aug 02 2022 18:33:15 GMT+0800 (China Standard Time)
// 目标的日期,5表示六月
var td = new Date(2021, 5, 7);
// 毫秒差,时间戳差
var diff = td - nd;
// 任务很简单,就是把diff换算为天、小时、分钟、秒
// 换算为多少天,除以一天的总毫秒数,不就是换算为多少天么
var day = parseInt(diff / (1000 * 60 * 60 * 24));//parseInt取整
// 零多少小时呢??差的总毫秒数与1天的毫秒数的相除的余数,就是零头的毫秒数
var hours = parseInt(diff % (1000 * 60 * 60 * 24) / (1000 * 60 * 60));
// 零多少分钟呢??
var minutes = parseInt(diff % (1000 * 60 * 60) / (1000 * 60));
// 零多少秒呢??
var seconds = parseInt(diff % (1000 * 60 * 60) % (1000 * 60) / 1000);
info.innerText = day + '天' + hours + '时' + minutes + '分' + seconds + '秒';
}, 1000);
</script>
</body>
边栏推荐
猜你喜欢
随机推荐
单例模式你会几种写法?
嗨!不来看一下如何骚气十足的登陆MySQL嘛?
UDP(用户数据报协议)
How to seize the new trend of NFT, yuan|universe|universe?
管理工具|宝藏书签收藏管理工具
[C题目]力扣234. 回文链表
Do you understand the factory pattern?
Ansible installation and configuration
golang刷leetcode:使数组按非递减顺序排列
group of people
成功解决TypeError: can‘t multiply sequence by non-int of type ‘float‘
【c】操作符详解(一)
搭建Spark开发环境(第二弹)
What is the core business model of the "advertising e-commerce" that has recently become popular in the circle of friends, and is the advertising revenue really reliable?
快速构建电脑软件系统 、超好用经典的网页推荐汇总
牛客刷题:数组排序
【3D视觉】深度摄像头与3D重建
hi!Don't look at how to SAO gas dye-in-the-wood in MySQL?
增删改查这么多年,最后栽在MySQL的架构设计上!
iptables、firewalld的使用








