如何在html网站上显示时间?

我想在网页旁边做个时间,方便知道时间,是随元素一起滚动的!我想要些代码

第1个回答  2013-10-12
<script language="javascript" type="text/javascript">
var enabled = 0; today = new Date();
var day; var date;
if(today.getDay()==0) day = "星期日 "
if(today.getDay()==1) day = "星期一 "
if(today.getDay()==2) day = "星期二 "
if(today.getDay()==3) day = "星期三 "
if(today.getDay()==4) day = "星期四 "
if(today.getDay()==5) day = "星期五 "
if(today.getDay()==6) day = "星期六 "
document.fgColor = " FF0072";
date1 =(today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ;
date2 = day ;
document.write(date1.fontsize(2));
document.write(date2.fontsize(2));
document.write("<span id='clock'></span>");
var now,hours,minutes,seconds,timeValue;
function showtime(){
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? " " : " ";
timeValue += hours+ ":";
timeValue += ((minutes < 10) ? "0" : "") + minutes + ":";
第2个回答  2017-08-05
http://www.htmleaf.com/html5/html5donghua/20141222960.html
找到个插件 你把它下载下来看看网站上的说明插入你自己的网页就行。定位用CSS的position属性就行了。