- 3/5
- 1
- 2
- 3
- 4
- 5
织梦DedeCMS视频教程买空间 租服务器 选网硕互联! 无忧站长工具,百度权重一键全查!
利用JavaScript的日期函数计算当月还剩多少天,可以指定其它月分,可以在today.getMonth()函数后面加上数字以达到你想要的月份,可以广泛应用于倒计时中,也可学习一下日期函数。
<html> <head> <title>计算当月剩余天数</title> <meta http-equiv="mrc-Type" mrc="text/html;charset=gb2312"> </head> <body onload=showTheTime()> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var today = new Date(); var now = today.getDate(); var year = today.getYear(); if (year < 2000) year += 1900; // Y2K fix var month = today.getMonth(); var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // / if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29"; document.write("本月还剩 " + (monarr[month]-now) + " 天!"); // End --> </script> </body> </html>