网页制作16-Javascipt时间特效の设置D-DAY倒计时

01、效果图

02、应用

  1. new Date()//返回今天日期

  2. new Date("April 1,2025")//返回目标日期

  3.  document.write()//文档显示

  4. getTime()返回当日毫秒数

  5.  Math.floor(amadays / (1000 * 60 * 60 * 24)//把毫秒换算天

03、代码

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
 <script> 
  var aim= new Date("April 1,2025"); 
  var aimday="愚人节"; 
  var today = new Date(); 
  var amadays = aim.getTime() - today.getTime(); 
  var remain = Math.floor(amadays / (1000 * 60 * 60 * 24)); //把毫秒换算天
  if (remain >= 0) ;
document.write("现在离2025年"+aimday+"还有: <font color=red><b>"+remain +"</b></font>天"+"<br>");
	 
	 document.write(aim+"<br>");//返回目标日期
	 document.write(today+"<br>");//返回今天日期
	  document.write( aim.getTime()+"<br>");//返回目标日期毫秒数
	 document.write(today.getTime()+"<br>");//返回当日毫秒树木数 document.write(amadays+"<br>");
	document.write(remain+"<br>");//返回今日与目标日的差值
</script>
<body>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值