想在网站的右上角放上 今天是几月几时星期几 几时几秒几分 应该怎么写js代码呢.并且更新到秒.就像
右上角一样的效果.哪位会啊javascript时间问题请教一下!
- 提问者网友:活着好累
- 2021-08-19 15:40
- 五星知识达人网友:思契十里
- 2021-08-19 16:14
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<body>
<div id="jnkc">
</div>
<script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
</script>
</body>
</html>
代码,这段代码可以精确到秒
- 1楼网友:风格不统一
- 2021-08-19 16:31
<script language="JavaScript" type="text/javascript"> today=new Date(); function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this.length;i++) this[i+1]=initArray.arguments[i] } document.write("<font color=black>",today.getYear(),"<font color=black>年","<font color=black>",today.getMonth()+1,"<font color=black>月","<font color=black>",today.getDate(),"<font color=black>日 </FONT>"); var d=new initArray("<font color=RED>星期日","<font color=black>星期一","<font color=black>星期二","<font color=black>星期三","<font color=black>星期四","<font color=black>星期五","<font color=red>星期六"); </script> <script language="JavaScript" type="text/javascript">document.write(d[today.getDay()+1]);</script> <span id="liveclock" 15px? height:="height:" 109px; style?="width:"></span> <script language="JavaScript" type="text/javascript"> function www_helpor_net() { var Digital=new Date() var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds()
if(minutes<=9) minutes="0"+minutes if(seconds<=9) seconds="0"+seconds myclock=hours+":"+minutes+":"+seconds if(document.layers){document.layers.liveclock.document.write(myclock) document.layers.liveclock.document.close() }else if(document.all) liveclock.innerHTML=myclock setTimeout("www_helpor_net()",1000) } www_helpor_net(); //--> </script>
这是他的源代码 应该可以
你可以看他的源代码