DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> javascript計算當月剩余天數(天數計算器)示例代碼
javascript計算當月剩余天數(天數計算器)示例代碼
編輯:關於JavaScript     

代碼如下:

復制代碼 代碼如下:
<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>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved