[天数计算器]js计算当月剩余天数示例代码

分类:Javascript| 发布:佚名| 查看: | 发表时间:2014/1/13

代码如下:


<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);

// check for leap year
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = "29";

// display day left
document.write("这个月还剩 " + (monarr[month]-now) + " 天了");
//  End -->
</script>

365据说看到好文章不转的人,服务器容易宕机
原创文章如转载,请注明:转载自郑州网建-前端开发 http://camnpr.com/
本文链接:http://camnpr.com/javascript/903.html

相关文章