网页制作中时间自动更新问题
发布网友
发布时间:2022-04-27 12:41
我来回答
共2个回答
热心网友
时间:2023-09-20 05:34
在你页面要添加时间中插入:
<script language="JavaScript">
<!--
var today1 = new Date()
var year=today1.getYear()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
function number(index1){
var numberstring="一二三四五六七*十";
if(index1 ==0) {document.write("十")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}
}
function number2(index2){
var numberstr="零一二三四五六七*";
var yearstr=index2.toString();
var n0=yearstr.substr(0,1);
var n1=yearstr.substr(1,1);
var n2=yearstr.substr(2,1);
var n3=yearstr.substr(3,1);
document.write(numberstr.substr(n0,1)+numberstr.substr(n1,1)+numberstr.substr(n2,1)+numberstr.substr(n3,1));
}
number2(year);
document.write("年")
number(month);
document.write("月");
number(date);
document.write("日");
//-->
</script>
参考资料:http://www.xhtmlhelp.net/javascript/17542.html
热心网友
时间:2023-09-20 05:35
js代码