www.whkt.net > jAvAsCript显示当前时间

jAvAsCript显示当前时间

<table width="778" border="0" align="center" cellpadding="0" cellspacing="0"><tr> <td width="584" height="47" background="images/bgtime.png" style="padding-left:40px;"> <script language="JavaScript"> //javascript

你这里有问题:document.write("当前时间显示:"y+"nian"+m+"yue"+d+"ri"); y前面少了一个+号 document.write("当前时间显示:"+y+"nian"+m+"yue"+d+"ri"); 这样就可以了

<script language="javascript" type="text/javascript">function update(){var time;time=new date(); hours=time.gethours(); mins=time.getminutes();document.getelementbyid("localtime").innerhtml=hours+":"+mins;}</script></head> <body onload="update()"><div id="localtime"></div>

var date = new Date();<br> var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];<br> var year = date.getFullYear();<br> var month = date.getMonth()+1;<br> var day = date.getDate();<br> var week = weekDay[date.getDay()];<br> alert(year+","+month+","+day+","+week)

<script language="javascript">function getCurDate(){var d = new Date();var week;switch (d.getDay()){case 1: week="星期一"; break;case 2: week="星期二"; break;case 3: week="星期三"; break;case 4: week="星期四"; break;

建议换成getFullYear试试.Javascript解析器应该是返回2013的,而浏览器则计算返回113,这就问题的原因. getYear、getFullYear、getUTCFullYear都是Javascript的Date对象的方法函数.其中getYear()方法出生较早,在早期也一直使用OK

<script>function tick() {var hours, minutes, seconds, xfile;var intHours, intMinutes, intSeconds;var today;var Clock = document.getElementById('Clock');today = new Date();intHours = today.getHours();intMinutes = today.getMinutes();intSeconds =

getdate()

<!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"><head><meta http-equiv="Content-Type" content="text/html

<div id="date"> </div><script type="text/javascript">function showTime(){ var $dt = document.getElementById("date"); // 得到容器对象 var dt = new Date(); // 得到当前时间 var y = dt.getFullYear(); // 当前年份 var m = dt.getMonth()

网站地图

All rights reserved Powered by www.whkt.net

copyright ©right 2010-2021。
www.whkt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com