关键词
ASP函数 时间字符串
摘要
本文介绍一个ASP生成时间字符串的函数,将年月日时分秒组合成一个14位的时间字符串。
我们在开发过程中,经常需要用到时间字符串。这个字符串可以用于生成临时文件名、随机文件名、加密校验的指纹等。年月日时分秒组合起来的时间字符串一共14位,不足两位要在前面补上一个零以凑足两位。
<% Public Function FormatDate(datetime) Dim y, m, d, h, i, s y = CStr(Year(datetime)) m = CStr(Month(datetime)) If Len(m) = 1 Then m = "0" & m d = CStr(Day(datetime)) If Len(d) = 1 Then d = "0" & d h = CStr(Hour(datetime)) If Len(h) = 1 Then h = "0" & h i = CStr(Minute(datetime)) If Len(i) = 1 Then i = "0" & i s = CStr(Second(datetime)) If Len(s) = 1 Then s = "0" & s FormatDate = y & "-" & m & "-" & d & " " & h & ":" & i & ":" & s End Function %>
关于ASP获取年月日时分秒的14位时间字符串的函数,本文就介绍这么多,希望对您有所帮助,谢谢!