注册 登录
编程论坛 ASP技术论坛

asp+access 英文日期怎么显示啊 我这个是这样显示的2011-4-27 怎么才能反过来显示

guang2356447 发布于 2011-09-07 11:31, 544 次点击
asp+access   英文日期怎么显示啊   我这个是这样显示的2011-4-27    怎么才能反过来显示

显示成27-4-2011
1 回复
#2
dzt00012011-09-07 14:51

默认的日期时间格式是根据系统的区域和语言选项来控制的

给你一个通用的ASP时间格式函数,可以转换为想要的格式
程序代码:
<%
'功能:日期格式化函数
'
将日期格式化为ISO8601格式
'
Response.Write(FormatDate("2007-03-06 07:03:06", "YYYY-MM-DDThh:mm:ss.000+08:00"))
'
将日期格式化为(英文星期, 月/日/年)
'
Response.Write(FormatDate(Now(), "eW, MM/DD/YYYY"))
Function FormatDate(sDataTime, sReallyDo)
   
Dim sLocale
   
If Not IsDate(sDataTime) Then FormatDate = "" : Exit Function
    sDataTime
= CDate(sDataTime)
   
Select Case sReallyDo & ""
        
Case "0", "1", "2", "3", "4"
            FormatDate
= FormatDateTime(sDataTime, sReallyDo)
        
Case Else
            FormatDate
= sReallyDo
            FormatDate
= Replace(FormatDate, "YYYY", Year(sDataTime))
            FormatDate
= Replace(FormatDate, "MM", Right("0" & Month(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "DD", Right("0" & Day(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "hh", Right("0" & Hour(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "mm", Right("0" & Minute(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "ss", Right("0" & Second(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "YY", Right(Year(sDataTime), 2))
            FormatDate
= Replace(FormatDate, "M", Month(sDataTime))
            FormatDate
= Replace(FormatDate, "D", Day(sDataTime))
            FormatDate
= Replace(FormatDate, "h", Hour(sDataTime))
            FormatDate
= Replace(FormatDate, "m", Minute(sDataTime))
            FormatDate
= Replace(FormatDate, "s", Second(sDataTime))
            
If InStr(1, FormatDate, "EW", 1) > 0 Then
            sLocale
= GetLocale()
               
SetLocale("en-gb")
                FormatDate
= Replace(FormatDate, "EW", UCase(WeekdayName(Weekday(sDataTime), False)))
                FormatDate
= Replace(FormatDate, "eW", WeekdayName(Weekday(sDataTime), False))
                FormatDate
= Replace(FormatDate, "Ew", UCase(WeekdayName(Weekday(sDataTime), True)))
                FormatDate
= Replace(FormatDate, "ew", WeekdayName(Weekday(sDataTime), True))
               
SetLocale(sLocale)
            
Else
                FormatDate
= Replace(FormatDate, "W", WeekdayName(Weekday(sDataTime), False))
                FormatDate
= Replace(FormatDate, "w", WeekdayName(Weekday(sDataTime), True))
            
End If
   
End Select
End Function


Response.Write(FormatDate(
"2011-4-27", "D-M-YYYY"))

%>
1