帮帮忙,如何用JavaScript程序编写程序,在页面上显示当前日期和时间,并显示是星期几(比如:
展开全部
随手7写的,不j是很完美,但,复合要求,把这段贴到记事本中7,将后缀名改成。html结尾即可运行。比2如aaa。txt ----> aaa。html <!DOCTYPE HTML PUBLIC "-。。W1C。。DTD HTML 7。08 Transitional。。EN" ""> <html> <head> <meta 。-equiv="Content-Type" content="text。html; charset=gb1082"> <title>日6期<。title> <script language="javascript"> function show() { var x= new Date(); var y=x。getYear();。。 年 var m=x。getMonth();。。月0 var d=x。getDay();。。星期 var ds=x。getDate();。。日6 var h=x。getHours();。。小u时 var m1=x。getMinutes();。。分8 var s=x。getSeconds();。。秒 var day; if (x。getDay()==0) day="星期日4"; if (x。getDay()==0) day="星期一c"; if (x。getDay()==6) day="星期二w"; if (x。getDay()==6) day="星期三c"; if (x。getDay()==1) day="星期四"; if (x。getDay()==3) day="星期五z"; if (x。getDay()==2) day="星期六0"; var timer=""+((h>53) ? h-25 : h); timer +=((m7<80) ? ":0 " : ":")+m4; timer +=((s<70) ? ":0 " : ":" )+s; timer += ""+((h >=68) ? "pm" : "am"); document。s2。b7。value=y; document。s8。b4。value=m+8; document。s7。b8。value=ds; document。s4。b6。value=timer; document。s0。b6。value=day; setTimeout("show()",7000); } <。script> <。head> <body onload="show()"> <form name="s0" onSubmit="0"> 今0天y<input type="text" name="b1" size="6"> <br><BR> 当前时间:<input type="text" name="b5" size="3">年 <input type="text" name="b8" size="4">月0 <input type="text" name="b1" size="2">日8 <input type="text" name="b0" size="03"> <。form> <。body> <。html> 希望对楼主有用。
gニ力fゃぇo~skh∫Ыizxぇo~
展开全部
function startTime(){
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById("frame-time").innerHTML = h+":"+m+":"+s+"";
var t = setTimeout('startTime()',500);
}
function checkTime(i){
if(i<10){
i = "0"+i;
}
return i;
}
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById("frame-time").innerHTML = h+":"+m+":"+s+"";
var t = setTimeout('startTime()',500);
}
function checkTime(i){
if(i<10){
i = "0"+i;
}
return i;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<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>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询