ページに時間を設定

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=' !&nbsp;'
  else if(hour < 9)hello=' !&nbsp;'
  else if(hour < 12)hello=' !&nbsp;'
  else if(hour < 14)hello=' !&nbsp;'
  else if(hour < 17)hello=' !&nbsp;'
  else if(hour < 19)hello=' !&nbsp;'
  else if(hour < 22)hello=' !&nbsp;'
  else {hello=' !&nbsp;'}
  day=today.getDay()
  if(day==0)day='&nbsp; '
  else if(day==1)day='&nbsp; '
  else if(day==2)day='&nbsp; '
  else if(day==3)day='&nbsp; '
  else if(day==4)day='&nbsp; '
  else if(day==5)day='&nbsp; '
  else if(day==6)day='&nbsp; '
  date=(today.getYear())+' '+(today.getMonth()+1)+' '+today.getDate()+' ';
  document.getElementById("welcomeWord").innerHTML = hello;
  document.getElementById("datetime").innerHTML = date + "&nbsp;&nbsp;&nbsp;&nbsp;" + day;
 }