js 写日期

时间:2022-01-18 05:27:57
<SCRIPT language="JavaScript" type="text/JavaScript">
  today = new Date();
  var day=""
  var date1=""
  if(today.getDay()==0) day = "星期日"
  else if(today.getDay()==1) day = "星期一"
  else if(today.getDay()==2) day = "星期二"
  else if(today.getDay()==3) day = "星期三"
  else if(today.getDay()==4) day = "星期四"
  else if(today.getDay()==5) day = "星期五"
  else if(today.getDay()==6) day = "星期六";
  if (today.getYear()>=2000)
  date1 = (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 ";
  else
  date1 = (1900 + today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 ";
  document.writeln(date1+day)
  </SCRIPT>