JavaScript 显示中文日期原代码

来源:互联网 发布:软件实现设计说明书 编辑:程序博客网 时间:2024/05/17 00:59
<html>
<head>fsdfsdf
</head>
<body>
<script LANGUAGE="JavaScript">
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 if(index1==30)
                         {
                             document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))
                         }
                         else
                         {
                             document.write("三十一")
                         }
}
function fun2(index_year)
{
    var numberstring="一二三四五六七八九十"
    document.write(numberstring.substring(0+(index_year-2001),(index_year-2000)))
}

var today1 = new Date()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
var year=today1.getFullYear()
alert(year);


document.write("<br><strong><small><center>")
document.write("公元二零零")
fun2(year);
document.write("年")
number(month)
document.write("月")
number(date)
document.write("日</small><center>")
</script>
</body>
</html>