主题:求助:用Javascript实现动态中文时间显示(就差一点了)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/javascript">
function number(today){
var numberstring="一二三四五六七八九十";
if(today==0){
document.write("十")
}
if(today<10){
document.write(numberstring.substring((today-1),today))
}
else if(today<20){
document.write("十"+numberstring.substring((today-11),(today-10)))
}
else if(today<30){
document.write("二十"+numberstring.substring((today-21),(today-20)))
}
else if(today<40){
document.write("三十"+numberstring.substring((today-31),(today-30)))
}
else if(today<50){
document.write("四十"+numberstring.substring((today-41),(today-40)))
}
else {
document.write("五十"+numberstring.substring((today-51),(today-50)))
}
}
function time(){
var mydate=new Date()
var year=mydate.getYear()
var month=mydate.getMonth()+1
var date=mydate.getDate()
var day=mydate.getDay()
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
document.write("公元二零零五年")
number(month)
document.write("月")
number(date)
document.write("日")
number(hours)
document.write("点")
number(minutes)
document.write("分")
number(seconds)
document.write("秒")
setTimeout( 'time()', 1000)
}
</script>
</head>
<body onLoad="time()">
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/javascript">
function number(today){
var numberstring="一二三四五六七八九十";
if(today==0){
document.write("十")
}
if(today<10){
document.write(numberstring.substring((today-1),today))
}
else if(today<20){
document.write("十"+numberstring.substring((today-11),(today-10)))
}
else if(today<30){
document.write("二十"+numberstring.substring((today-21),(today-20)))
}
else if(today<40){
document.write("三十"+numberstring.substring((today-31),(today-30)))
}
else if(today<50){
document.write("四十"+numberstring.substring((today-41),(today-40)))
}
else {
document.write("五十"+numberstring.substring((today-51),(today-50)))
}
}
function time(){
var mydate=new Date()
var year=mydate.getYear()
var month=mydate.getMonth()+1
var date=mydate.getDate()
var day=mydate.getDay()
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
document.write("公元二零零五年")
number(month)
document.write("月")
number(date)
document.write("日")
number(hours)
document.write("点")
number(minutes)
document.write("分")
number(seconds)
document.write("秒")
setTimeout( 'time()', 1000)
}
</script>
</head>
<body onLoad="time()">
</body>
</html>