神站网↪有时候喝一点酒,借着冷冷的月光总翻来覆去,想不明白我为什么要下凡↩

JS获取年月日,当前时间和星期几


<b id="date"><script type="text/javascript">  //若小于10,前置加0  function add_zero(i){if(i<10){ i="0"+i; };return i;  }  var week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");  var month=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");  var d=new Date();  dInfo=d.getFullYear()+"年";//dInfo+=d.getFullYear()%100+"&nbsp;";  dInfo+=month[d.getMonth()];  dInfo+=d.getDate()+"日&nbsp;";  dInfo+=week[d.getDay()]+"&nbsp;";  document.getElementById("date").innerHTML=dInfo;</script></b><b id="hms"><script type="text/javascript">//js获取实时时分秒function hms(){var d=new Date();h=add_zero(d.getHours())+":";m=add_zero(d.getMinutes())+":";s=add_zero(d.getSeconds());document.getElementById("hms").innerHTML=h+m+s;setTimeout(hms,1000);}hms();</script></b>

更新时间 收藏 点赞 3 打赏 浏览 296 

恢复多功能编辑器
      全部留言
  • 0
更多回复
账号: