合肥超五星级酒店:谁嫩给我一段显示时间的代码!谢谢

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/11 01:10:38

<script language="JavaScript">
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate();
myyear= mydate.getYear();
year=(myyear > 200) ? myyear : 1900 + myyear;
if(myweekday == 0) weekday=" 星期日 ";
else if(myweekday == 1) weekday=" 星期一 ";
else if(myweekday == 2) weekday=" 星期二 ";
else if(myweekday == 3) weekday=" 星期三 ";
else if(myweekday == 4) weekday=" 星期四 ";
else if(myweekday == 5) weekday=" 星期五 ";
else if(myweekday == 6) weekday=" 星期六 ";
document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday);
</script>

你要什么语言的啊?

如果你需要在网页中显示,可以采用下面的代码:
1、年、月、日、小时、分钟、秒、星期的算法:
<%
Trst=now()
shi = Hour(Trst)
nian=Year(Trst)
fen=Minute(Trst)
yue=Month(Trst)
xing =Weekday(Trst)-1
miao= Second(Trst)
ri =Day(Trst)
if xing="0" then xing = "日"
if xing="1" then xing = "一"
if xing="2" then xing = "二"
if xing="3" then xing = "三"
if xing="4" then xing = "四"
if xing="5" then xing = "五"
if xing="6" then xing = "六"
%>
最后年的变量是:nian,月的变量是:yue,日的变量是:ri,星期的变量是:xing,时的变量是:shi,分的变量是:fen,秒的变量是:miao
2、动态显示时分秒:
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = ""
timeValue += ((hours <10) ? "0":"") + hours
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</SCRIPT>
最后的显示方法是:
<body onload=startclock()><form name=clock >
<input name=thetime style="font-size:11pt;color:#0000FF;border:2px none; " size=8></form></body>