倒计时
来源:互联网 发布:心动网络 笔试题目 编辑:程序博客网 时间:2024/05/21 10:08
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p>距离2018年1月1日还有 天 小时 分钟 秒</p>
</body>
<script type="text/javascript">
var ip = document.getElementsByTagName('p')[0];
//创建一个时间对象
var nowDate = new Date(2018,0,1);
var nowYear = nowDate.getFullYear();//返回当前的年份
console.log(nowYear);
var nowMonth = nowDate.getMonth();//返回当前的月份
console.log(nowMonth);
var nowDay = nowDate.getDay();//返回当前的日期
console.log(nowDay);
var nowHour = nowDate.getHours();//返回当前小时
console.log(nowHour);
var nowMinute = nowDate.getMinutes();//返回当前分钟
console.log(nowMinute);
var nowSecond = nowDate.getSeconds();//返回当前秒
console.log(nowSecond);
var nowWeek = nowDate.getDay();//返回当前星期几
console.log(nowWeek);
var nowTime = nowDate.getTime();//返回当前时间到1970.1.1毫秒数
console.log(nowTime);
//定义一个定时器,每隔一秒输出
var timer = setInterval(function(){
var nowDate1 =new Date();
var nowTime1 = nowDate1.getTime();
console.log(nowTime1);
//得到天数
var day =parseInt((nowTime-nowDate1)/(3600*24*1000));
console.log(day);
//得到小时数
var hour=parseInt((nowTime-nowDate1)%(3600*24*1000)/(3600*1000));
console.log(hour);
//得到分钟数
var minute = parseInt(((nowTime-nowDate1)%(3600*24*1000)%(3600*1000)/60/1000));
console.log(minute);
//得到秒数
var seconds=parseInt(((nowTime-nowDate1)%(3600*24*1000)%(3600*1000)%(60*1000)/1000));
console.log(seconds);
ip.innerHTML ='距离2018年1月1日还有'+day+'天'+hour+'小时'+minute+'分钟'+seconds+'秒';
},1000);
</script>
</html>
<html>
<head>
<title></title>
</head>
<body>
<p>距离2018年1月1日还有 天 小时 分钟 秒</p>
</body>
<script type="text/javascript">
var ip = document.getElementsByTagName('p')[0];
//创建一个时间对象
var nowDate = new Date(2018,0,1);
var nowYear = nowDate.getFullYear();//返回当前的年份
console.log(nowYear);
var nowMonth = nowDate.getMonth();//返回当前的月份
console.log(nowMonth);
var nowDay = nowDate.getDay();//返回当前的日期
console.log(nowDay);
var nowHour = nowDate.getHours();//返回当前小时
console.log(nowHour);
var nowMinute = nowDate.getMinutes();//返回当前分钟
console.log(nowMinute);
var nowSecond = nowDate.getSeconds();//返回当前秒
console.log(nowSecond);
var nowWeek = nowDate.getDay();//返回当前星期几
console.log(nowWeek);
var nowTime = nowDate.getTime();//返回当前时间到1970.1.1毫秒数
console.log(nowTime);
//定义一个定时器,每隔一秒输出
var timer = setInterval(function(){
var nowDate1 =new Date();
var nowTime1 = nowDate1.getTime();
console.log(nowTime1);
//得到天数
var day =parseInt((nowTime-nowDate1)/(3600*24*1000));
console.log(day);
//得到小时数
var hour=parseInt((nowTime-nowDate1)%(3600*24*1000)/(3600*1000));
console.log(hour);
//得到分钟数
var minute = parseInt(((nowTime-nowDate1)%(3600*24*1000)%(3600*1000)/60/1000));
console.log(minute);
//得到秒数
var seconds=parseInt(((nowTime-nowDate1)%(3600*24*1000)%(3600*1000)%(60*1000)/1000));
console.log(seconds);
ip.innerHTML ='距离2018年1月1日还有'+day+'天'+hour+'小时'+minute+'分钟'+seconds+'秒';
},1000);
</script>
</html>
阅读全文
0 0
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时、、、、、
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- 倒计时
- LintCode:M-带环链表
- 【Java学习笔记】36:泛型的类型变量的限定
- 编译动态库和静态库的Makefile模板
- 平衡二叉树的实现代码加详细注释
- opencv:批量读取一个文件夹下的图片,并转换成视频
- 倒计时
- Save and Load Your Keras Deep Learning Models
- webview中的img标签加载Android本地的图片
- 30岁后还能入IT行业吗?
- HTML5 canvas粒子烟花绽放动画
- Heibernate三种状态
- Spring 代理中的静态代理、动态代理
- 新版JS--函数参数默认值
- require,import区别