asp中如何在网页上输入中文日期
我们通常需要在web页面上写上当前的日期,可能使用客户端script,或者使用asp。使用asp的一个特点是,它产生的效果看起来是静态的页面,但实际上它是动态生成的。如果你希望用asp显示一个中文的日期,则需要转化一下。 下面是用来转化的函数及其调用实例。
< %
’======================================================
’ 函数 date2chinese
’ 功能:获得中文日期的字符串(如一九九八年五月十二日)
’ 参数: idate 要转化的日期
’ 返回: 中文日期的字符串
’======================================================
function date2chinese(idate)
dim num(10)
dim iyear
dim imonth
dim iday
num(0) = "〇"
num(1) = "一"
num(2) = "二"
num(3) = "三"
num(4) = "四"
num(5) = "五"
num(6) = "六"
num(7) = "七"
num(8) = "八"
num(9) = "九"
iyear = year(idate)
imonth = month(idate)
iday = day(idate)
date2chinese = num(iyear \ 1000) + _
num((iyear \ 100) mod 10) + num((iyear _
\ 10) mod 10) + num(iyear mod _
10) + "年"
if imonth >= 10 then
if imonth = 10 then
date2chinese = date2chinese + _
"十" + "月"
else
date2chinese = date2chinese + _
"十" + num(imonth mod 10) + "月"
end if
else
date2chinese = date2chinese + _
num(imonth mod 10) + "月"
end if
if iday >= 10 then
if iday = 10 then
date2chinese = date2chinese + _
"十" + "日"
elseif iday = 20 or iday = 30 then
date2chinese = date2chinese + _
num(iday \ 10) + "十" + "日"
elseif iday > 20 then
date2chinese = date2chinese + _
num(iday \ 10) + "十" + _
num(iday mod 10) + "日"
else
date2chinese = date2chinese + _
"十" + num(iday mod 10) + "日"
end if
else
date2chinese = date2chinese + _
num(iday mod 10) + "日"
end if
end function
%>
可以在网页的任何地方使用以下输出中文日期:
< %
response.write date2chinese(date())
%>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器