window.onload=showday; year=2024; //年 mon=05+0; //月 day=1; //日 time=0; //時 xday = new Date(year,mon-1,day,time,00,00);//基準になる年月日 function showday() { nowday = new Date(); passtime= xday.getTime()-nowday.getTime(); //今から基準になる日までの経過時間 1/1000秒単位 cnt_day = Math.floor(passtime/(1000*60*60*24));// カウントダウン表示 (日にち) の取得 passtime = passtime -(cnt_day*(1000*60*60*24)); // 経過秒から(日にち)を引く cnt_hour = Math.floor(passtime/(1000*60*60));// カウントダウン表示 (時) の取得 passtime = passtime -(cnt_hour*(1000*60*60)); // 経過秒から(時)を引く cnt_min = Math.floor(passtime/(1000*60)); // カウントダウン表示 (分) 取得 passtime = passtime -(cnt_min*(1000*60));// 経過秒から(分)を引く cnt_sec = Math.floor(passtime/1000);// カウントダウン表示 (秒) 取得 passtime = passtime -(cnt_sec*(1000)); // 経過秒から(秒)を引く cnt_millisec = Math.floor(passtime/10); // カウントダウン表示 (100/1秒) 取得 // 分、秒、ミリ秒を2桁で表示する。 if(cnt_min<10){cnt_min = '0' + cnt_min;} if(cnt_sec<10){cnt_sec = '0' + cnt_sec;} if(cnt_millisec<10){cnt_millisec = '0' + cnt_millisec;} if((xday - nowday) > 0){ document.tbox.dspday.value = ""+cnt_day+"日と "+cnt_hour+"時間"+cnt_min+"分"+cnt_sec+"秒"+cnt_millisec; } else { document.tbox.dspday.value = "カウントダウンは終了。" } timerID = setTimeout('showday()', 10); }