asp.net C# 如何显示时间 要秒跳动显示的那种?

2025-01-19 02:26:13
推荐回答(2个)
回答1:





显示动态时间







将当前日期转换成字符串




回答2:



type="text/javascript">
function
startTime()
{
var
today=new
Date()
var
h=today.getHours()
var
m=today.getMinutes()
var
s=today.getSeconds()
//
add
a
zero
in
front
of
numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}
function
checkTime(i)
{
if
(i<10)
{i="0"
+
i}
return
i
}


显示动态时间

onload="startTime()">
id="txt">


type="text/javascript">
var
d=new
Date()
var
weekday=new
Array(7)
weekday[0]="Sunday"
weekday[1]="Monday"
weekday[2]="Tuesday"
weekday[3]="Wednesday"
weekday[4]="Thursday"
weekday[5]="Friday"
weekday[6]="Saturday"
document.write("Today
it
is
"
+
weekday[d.getDay()])



将当前日期转换成字符串

type="text/javascript">
var
d
=
new
Date()
document.write
(d.toUTCString())


相关问答