用html制作网页,怎么在网页中动态显示当前时间,代码怎么写?
2个回答
展开全部
今天是<script language="javascript">
var mydate=new Date();
var mymonth=mydate.getMonth()+1;
var myday= mydate.getDate();
var myyear= mydate.getYear();
document.write(myyear+"-"+mymonth+"-"+myday);</script>,欢迎访问XX网
把上面部分复制到记事本后,再从记事本直接复制到网页代码中(记事本过渡一下,是为了去掉所有格式),代码已测试过
var mydate=new Date();
var mymonth=mydate.getMonth()+1;
var myday= mydate.getDate();
var myyear= mydate.getYear();
document.write(myyear+"-"+mymonth+"-"+myday);</script>,欢迎访问XX网
把上面部分复制到记事本后,再从记事本直接复制到网页代码中(记事本过渡一下,是为了去掉所有格式),代码已测试过
展开全部
<script>
var mydate = new Date();
document.writeln("Year:"+mydate.getFullYear()+'<br>');
document.writeln("Month:"+(mydate.getMonth()+1)+'<br>');
document.writeln("Date:"+mydate.getDate()+'<br>');
document.writeln("Hours:"+mydate.getHours()+'<br>');
document.writeln("Minutes:"+mydate.getMinutes()+'<br>');
document.writeln("Seconds:"+mydate.getSeconds()+'<br>');
//星期几转成大写的
var weekDay = new Array('日','一','二','三','四','五','六');
var a = mydate.getDay()
document.writeln("WeekDay:"+weekDay[a]+'<br>');
// var str = "日一二三四五六".charAt(mydate.getDay());
// document.writeln("星期:" +str);
</script>
var mydate = new Date();
document.writeln("Year:"+mydate.getFullYear()+'<br>');
document.writeln("Month:"+(mydate.getMonth()+1)+'<br>');
document.writeln("Date:"+mydate.getDate()+'<br>');
document.writeln("Hours:"+mydate.getHours()+'<br>');
document.writeln("Minutes:"+mydate.getMinutes()+'<br>');
document.writeln("Seconds:"+mydate.getSeconds()+'<br>');
//星期几转成大写的
var weekDay = new Array('日','一','二','三','四','五','六');
var a = mydate.getDay()
document.writeln("WeekDay:"+weekDay[a]+'<br>');
// var str = "日一二三四五六".charAt(mydate.getDay());
// document.writeln("星期:" +str);
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询