年 月 日 时 分 秒 星期 。 如果按楼主要求,星期换下就可以,也就是
var ndate = years+"年"+month+"月"+days+"日 "+hours+":"+minutes+":"+seconds+" "+week;
这句 ,换成
var ndate = years+"年"+month+"月"+days+"日 "+week+" "+hours+":"+minutes+":"+seconds;
<html>
<head>
<title></title>
<script language="javascript">
function getCurDate()
{
var d = new Date();
var week;
switch (dgetDay()){
case 1: week="星期一"; break;
case 2: week="星期二"; break;
case 3: week="星期三"; break;
case 4: week="星期四"; break;
case 5: week="星期五"; break;
case 6: week="星期六"; break;
default: week="星期天";
}
var years = dgetYear();
var month = add_zero(dgetMonth()+1);
var days = add_zero(dgetDate());
var hours = add_zero(dgetHours());
var minutes = add_zero(dgetMinutes());
var seconds=add_zero(dgetSeconds());
var ndate = years+"年"+month+"月"+days+"日 "+hours+":"+minutes+":"+seconds+" "+week;
divTinnerHTML= ndate;
}
function add_zero(temp)
{
if(temp<10) return "0"+temp;
else return temp;
}
setInterval("getCurDate()",100);
</script>
</head>
<body>
<div id="divT"></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 40 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function nowaa() {
windowstatus = "当前系统时间:" + new Date()toLocaleString();
setInterval('nowaa()',1000);
}
nowaa();
//-->
</SCRIPT>
</BODY>
</HTML>
关于Date的更多信息,请查看:>
function showTime() {
var now = new Date();
var nowTime = nowtoLocaleString();
var date = nowTimesubstring(0,10);//截取日期
var time = nowTimesubstring(10,20); //截取时间
var week = nowgetDay(); //星期
var hour = nowgetHours(); //小时
//判断星期几
var weeks = ["日","一","二","三","四","五","六"];
var getWeek = "星期" + weeks[week];
var sc;
//判断是AM or PM
if(hour >= 0 && hour < 5){
sc = '凌晨';
}
else if(hour > 5 && hour <= 7){
sc = '早上';
}
else if(hour > 7 && hour <= 11){
sc = '上午';
}
else if(hour > 11 && hour <= 13){
sc = '中午';
}
else if(hour> 13 && hour <= 18){
sc = '下午';
}
else if(hour > 18 && hour <= 23){
sc = '晚上';
}
documentgetElementById('time')innerHTML ="当前时间:" + date+" " + getWeek +" "+" "+sc+" "+time;
setTimeout('showTime()',1000);
}
</script>
调用方法:
<body onload="showTime()">
<div id="time"></div>
</body>
2简洁的办法: 显示格式: 当前时间: 2010年6月1日 10:00:00 星期一
<htmtl>
<head></head>
<body>
<div id="linkweb" style=" display:inline;"></div>
<script>
setInterval("documentgetElementById('linkweb')innerHTML=new Date ()toLocaleString()+' 星期'+'日一二三四五六'charAt(new Date()getDay ());",1000);
</script>
</body>
</html>
todayDate = new Date();
date = todayDategetDate();
month= todayDategetMonth() +1;
year= todayDategetYear();
documentwrite("今天是")
documentwrite("<br>")
if(navigatorappName == "Netscape")
{
documentwrite(1900+year);
documentwrite("年");
documentwrite(month);
documentwrite("月");
documentwrite(date);
documentwrite("日");
documentwrite("<br>")
}
if(navigatorappVersionindexOf("MSIE") != -1)
{
documentwrite(year);
documentwrite("年");
documentwrite(month);
documentwrite("月");
documentwrite(date);
documentwrite("日");
}
if (todayDategetDay() == 5) documentwrite("星期五")
if (todayDategetDay() == 6) documentwrite("星期六")
if (todayDategetDay() == 0) documentwrite("星期日")
if (todayDategetDay() == 1) documentwrite("星期一")
if (todayDategetDay() == 2) documentwrite("星期二")
if (todayDategetDay() == 3) documentwrite("星期三")
if (todayDategetDay() == 4) documentwrite("星期四")
以上就是关于如何在js里获取系统时间,并在html中应用;全部的内容,包括:如何在js里获取系统时间,并在html中应用;、在js里面获取当系统实时时间并显示、js如何获得系统时间年月日时分秒等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)