[Back]

Count Down
〜特定の日付までのカウントダウン 〜


■ プレビュー

日付のカウントダウン


2003年1月1日まで、あと

■ ソース

<SCRIPT Language="JavaScript">
<!--
function getCountDownDay(theYear,theMonth,theDate)
{
        theMonthName = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
        today    = new Date();
        endDay   = theMonthName[theMonth-1]+" "+theDate+","+theYear;
        endToday = new Date(endDay);
        dayCount = 24 * 60 * 60 * 1000;
        countDay = (endToday.getTime() - today.getTime()) / dayCount;
        return Math.floor(countDay)+1;
}
// -->
</SCRIPT>

■ 使い方

  1. 上のプログラムを、文章を表示したいhtmlファイルにコピーして下さい。
  2. 日付を表示したい部分に、次のように記述してください。
    日付のカウントダウン
    <BR>
    2002年1月1日まで、あと
    <SCRIPT Language="JavaScript"><!--
            document.write(getCountDownDay(2003,1,1));
    // --></SCRIPT>
    日<BR>
  3. getCountDownDay(___)のところにカウントダウンしたい日付を入れます。