标题: 时间格式的统一 [打印本页] 作者: 新时代 时间: 2010-1-9 01:29 标题: 时间格式的统一 <%
Function AddZero(val, digit)
Dim Ret
Ret = CStr(val)
Ret = Replace(Space(digit - Len(val)), " ", "0") & Ret
AddZero = ret
End Function
Function MFormatDataTime(dt, format)
Dim ret
ret = Replace(format, "MM", Month(dt))
ret = Replace(ret, "M",AddZero(Month(dt), 2))
ret = Replace(ret, "mm",Minute(dt) )
ret = Replace(ret, "m", AddZero(Minute(dt), 2))
ret = UCase(ret)
ret = Replace(ret, "YYYY", Year(dt))
ret = Replace(ret, "DD", Day(dt))
ret = Replace(ret, "D", AddZero(Day(dt), 2))
ret = Replace(ret, "HH", Hour(dt))
ret = Replace(ret, "H", AddZero(Hour(dt), 2))
ret = Replace(ret, "SS", Second(dt))
ret = Replace(ret, "S", AddZero(Second(dt), 2))
MFormatDataTime = ret
End Function