首页 > 代码库 > 网页时间显示

网页时间显示

简单一点的网页时间显示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />	<title>time</title></head><body>	</body></html><script>    clock();    setInterval(clock,1000);    function clock(){        var oDate = new Date();        var year = oDate.getFullYear();        var month = oDate.getMonth()+1;        var date = oDate.getDate();        var week = ‘星期‘+‘日一二三四五六‘.charAt(oDate.getDay());        var hour = oDate.getHours();        var time = oDate.getMinutes();        var second = oDate.getSeconds();        var str = year+‘年‘+month + ‘月‘+ date+ ‘日‘+week+ ‘‘+toTwo(hour)+‘时‘+toTwo(time)+‘分‘+toTwo(second)+‘秒‘;        document.body.innerHTML=str;    }    function toTwo(n){        if(n < 10){            return ‘0‘+ n;        }else{            return n+‘‘;        }    }</script>

  

网页时间显示