邮件服务器-邮件系统-邮件技术论坛(BBS)

标题: 求助,帮写个转换成中文的函数 [打印本页]

作者: dxlx    时间: 2008-8-4 17:03
标题: 求助,帮写个转换成中文的函数
<%= etime&"-"&WeekDay(etime)%>
显示效果例如:2008年7月28日 20:30:01(星期一)
作者: Juven    时间: 2008-8-5 19:03

  1. response.write ShowDataInfo(now(),"Y年m月d日 H:I:S 周")
  2. Function ShowDataInfo(DateTime,ShowType)
  3.         if isBlank(DateTime) then Exit Function
  4.         Dim DateMonth,DateDay,DateHour,DateMinute,DateWeek,DateSecond
  5.         Dim FullWeekday,shortWeekday,WeekdayCN,Fullmonth,Shortmonth,TimeZone1,TimeZone2
  6.         TimeZone1="+0800"
  7.         TimeZone2="+08:00"
  8.         FullWeekday=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  9.         shortWeekday=Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
  10.         WeekdayCN=Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
  11.         Fullmonth=Array("January","February","March","April","May","June","July","August","September","October","November","December")
  12.         Shortmonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

  13.         DateMonth=Month(DateTime)
  14.         DateDay=Day(DateTime)
  15.         DateHour=Hour(DateTime)
  16.         DateMinute=Minute(DateTime)
  17.         DateWeek=weekday(DateTime)
  18.         DateSecond=Second(DateTime)
  19.         if Len(DateMonth)<2 then DateMonth="0"&DateMonth
  20.         if Len(DateDay)<2 then DateDay="0"&DateDay
  21.         if Len(DateMinute)<2 then DateMinute="0"&DateMinute
  22.         Select Case ShowType
  23.                 Case "Y-m-d" ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay
  24.                 Case "m.d" ShowDataInfo=DateMonth&"."&DateDay
  25.                 Case "Y.m.d" ShowDataInfo=Year(DateTime)&"."&DateMonth&"."&DateDay
  26.                 Case "Y-m-d w" ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&FullWeekday(DateWeek-1)
  27.                 Case "Y年m月d日" ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日"
  28.                 Case "Y年m月d日 周"  ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日 "&WeekdayCN(DateWeek-1)
  29.                 Case "Y年m月d日 H:I:S 周"  ShowDataInfo=Year(DateTime)&"年"&DateMonth&"月"&DateDay&"日 "&DateHour&":"&DateMinute&":"&DateSecond&" "&WeekdayCN(DateWeek-1)       
  30.                 Case "Y-m-d H:I A"
  31.                         Dim DateAMPM
  32.                         if DateHour>12 then
  33.                                 DateHour=DateHour-12
  34.                                 DateAMPM="PM"
  35.                         else
  36.                                 DateHour=DateHour
  37.                                 DateAMPM="AM"
  38.                         end if
  39.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  40.                         ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&" "&DateAMPM
  41.                 Case "Y-m-d H:I:S"
  42.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  43.                         if Len(DateSecond)<2 then DateSecond="0"&DateSecond
  44.                         ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond
  45.                 Case "Y-m-d H:I:S w"
  46.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  47.                         if Len(DateSecond)<2 then DateSecond="0"&DateSecond
  48.                         ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&FullWeekday(DateWeek-1)                       
  49.                 Case "YmdHIS"
  50.                         DateSecond=Second(DateTime)
  51.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  52.                         if Len(DateSecond)<2 then DateSecond="0"&DateSecond
  53.                         ShowDataInfo=Year(DateTime)&DateMonth&DateDay&DateHour&DateMinute&DateSecond       
  54.                 Case "ym" ShowDataInfo=Right(Year(DateTime),2)&DateMonth
  55.                 Case "d" ShowDataInfo=DateDay
  56.                 Case "ymd" ShowDataInfo=Right(Year(DateTime),4)&DateMonth&DateDay
  57.                 Case "mdy"
  58.                         Dim DayEnd
  59.                         Select Case DateDay
  60.                                 Case 1 DayEnd="st"
  61.                                 Case 2 DayEnd="nd"
  62.                                 Case 3 DayEnd="rd"
  63.                                 Case else DayEnd="th"
  64.                         End Select
  65.                         ShowDataInfo=Fullmonth(DateMonth-1)&" "&DateDay&DayEnd&" "&Right(Year(DateTime),4)
  66.                 Case "w,d m y H:I:S"
  67.                         DateSecond=Second(DateTime)
  68.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  69.                         if Len(DateSecond)<2 then DateSecond="0"&DateSecond
  70.                         ShowDataInfo=shortWeekday(DateWeek-1)&","&DateDay&" "& Left(Fullmonth(DateMonth-1),3) &" "&Right(Year(DateTime),4)&" "&DateHour&":"&DateMinute&":"&DateSecond&" "&TimeZone1
  71.                 Case "y-m-dTH:I:S"
  72.                         if Len(DateHour)<2 then DateHour="0"&DateHour       
  73.                         if Len(DateSecond)<2 then DateSecond="0"&DateSecond
  74.                         ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&"T"&DateHour&":"&DateMinute&":"&DateSecond&TimeZone2
  75.                 Case else
  76.                         if Len(DateHour)<2 then DateHour="0"&DateHour
  77.                         ShowDataInfo=Year(DateTime)&"-"&DateMonth&"-"&DateDay&" "&DateHour&":"&DateMinute
  78.         End Select
  79. End Function
复制代码

作者: xlas    时间: 2008-8-6 10:10
顶一下二楼先。。
作者: dxlx    时间: 2008-8-6 15:52
谢谢,代码很好





欢迎光临 邮件服务器-邮件系统-邮件技术论坛(BBS) (http://5dmail.net/bbs/) Powered by Discuz! X3.2