邮件服务器-邮件系统-邮件技术论坛(BBS)
标题:
求助,帮写个转换成中文的函数
[打印本页]
作者:
dxlx
时间:
2008-8-4 17:03
标题:
求助,帮写个转换成中文的函数
<%= etime&"-"&WeekDay(etime)%>
显示效果例如:2008年7月28日 20:30:01(星期一)
作者:
Juven
时间:
2008-8-5 19:03
response.write ShowDataInfo(now(),"Y年m月d日 H:I:S 周")
Function ShowDataInfo(DateTime,ShowType)
if isBlank(DateTime) then Exit Function
Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
Dim FullWeekday,shortWeekday,WeekdayCN,Fullmonth,Shortmonth,TimeZone1,TimeZone2
TimeZone1="+0800"
TimeZone2="+08:00"
FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
WeekdayCN=Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
DateMonth=Month(DateTime)
DateDay=Day(DateTime)
DateHour=Hour(DateTime)
DateMinute=Minute(DateTime)
DateWeek=weekday(DateTime)
DateSecond=Second(DateTime)
if Len(DateMonth)<2 then DateMonth="0"&DateMonth
if Len(DateDay)<2 then DateDay="0"&DateDay
if Len(DateMinute)<2 then DateMinute="0"&DateMinute
Select Case ShowType
Case "Y-m-d" ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay
Case "m.d" ShowDataInfo=DateMonth&"."&DateDay
Case "Y.m.d" ShowDataInfo=Year(DateTime)&"."&DateMonth&"."&DateDay
Case "Y-m-d w" ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&FullWeekday(DateWeek-1)
Case "Y年m月d日" ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日"
Case "Y年m月d日 周" ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日 "&WeekdayCN(DateWeek-1)
Case "Y年m月d日 H:I:S 周" ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日 "&DateHour&":"&DateMinute&":"&DateSecond&" "&WeekdayCN(DateWeek-1)
Case "Y-m-d H:I A"
Dim DateAMPM
if DateHour>12 then
DateHour=DateHour-12
DateAMPM="PM"
else
DateHour=DateHour
DateAMPM="AM"
end if
if Len(DateHour)<2 then DateHour="0"&DateHour
ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
Case "Y-m-d H:I:S"
if Len(DateHour)<2 then DateHour="0"&DateHour
if Len(DateSecond)<2 then DateSecond="0"&DateSecond
ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
Case "Y-m-d H:I:S w"
if Len(DateHour)<2 then DateHour="0"&DateHour
if Len(DateSecond)<2 then DateSecond="0"&DateSecond
ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&FullWeekday(DateWeek-1)
Case "YmdHIS"
DateSecond=Second(DateTime)
if Len(DateHour)<2 then DateHour="0"&DateHour
if Len(DateSecond)<2 then DateSecond="0"&DateSecond
ShowDataInfo=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond
Case "ym" ShowDataInfo=Right(Year(DateTime),2)&DateMonth
Case "d" ShowDataInfo=DateDay
Case "ymd" ShowDataInfo=Right(Year(DateTime),4)&DateMonth&DateDay
Case "mdy"
Dim DayEnd
Select Case DateDay
Case 1 DayEnd="st"
Case 2 DayEnd="nd"
Case 3 DayEnd="rd"
Case else DayEnd="th"
End Select
ShowDataInfo=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
Case "w,d m y H:I:S"
DateSecond=Second(DateTime)
if Len(DateHour)<2 then DateHour="0"&DateHour
if Len(DateSecond)<2 then DateSecond="0"&DateSecond
ShowDataInfo=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
Case "y-m-dTH:I:S"
if Len(DateHour)<2 then DateHour="0"&DateHour
if Len(DateSecond)<2 then DateSecond="0"&DateSecond
ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
Case else
if Len(DateHour)<2 then DateHour="0"&DateHour
ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
End Select
End Function
复制代码
作者:
xlas
时间:
2008-8-6 10:10
顶一下二楼先。。
作者:
dxlx
时间:
2008-8-6 15:52
谢谢,代码很好
欢迎光临 邮件服务器-邮件系统-邮件技术论坛(BBS) (http://5dmail.net/bbs/)
Powered by Discuz! X3.2