程式碼如下: 複製代碼 代碼如下: <P><!-- Begin<BR>var today = new Date();<BR>var now = today.getDate();<BR>var year = today.getYear();<BR>if (year < 2000) year = 1900; // Y2K fix<BR>var month = today.getMonth(); <P>var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); <P>// check for leap year<BR>if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monarr[1] = " 29"; <P>// display day left<BR>document.write("這個月剩下" (monarr[month]-now) " 天了");<BR>// End --><BR>