ページに時間を設定
1447 ワード
<span class="datetime" id="datetime"> </span>
<span id="welcomeWord"> span>
function setDateTime(){
today=new Date();
var day;
var date;
var hello;
hour=today.getHours()
if(hour < 6)hello=' ! '
else if(hour < 9)hello=' ! '
else if(hour < 12)hello=' ! '
else if(hour < 14)hello=' ! '
else if(hour < 17)hello=' ! '
else if(hour < 19)hello=' ! '
else if(hour < 22)hello=' ! '
else {hello=' ! '}
day=today.getDay()
if(day==0)day=' '
else if(day==1)day=' '
else if(day==2)day=' '
else if(day==3)day=' '
else if(day==4)day=' '
else if(day==5)day=' '
else if(day==6)day=' '
date=(today.getYear())+' '+(today.getMonth()+1)+' '+today.getDate()+' ';
document.getElementById("welcomeWord").innerHTML = hello;
document.getElementById("datetime").innerHTML = date + " " + day;
}