ASP format Date-time format code _ Application Tips
Source: Internet
Author: User
' ============================================
' Format time (display)
' Parameter: N_flag
' 1: "Yyyy-mm-dd hh:mm:ss"
' 2: "Yyyy-mm-dd"
' 3: "Hh:mm:ss"
' 4: "YYYY year mm month DD Day"
' 5: "YYYYMMDD"
' ============================================
Function format_time (S_time, N_flag)
Dim y, M, D, H, MI, s
Format_time = ""
If IsDate (s_time) = False Then Exit Function
y = CStr (year (s_time))
m = CStr (month (s_time))
If len (m) = 1 Then m = "0" & M
D = CStr (Day (s_time))
If len (d) = 1 Then D = "0" & D
h = CStr (Hour (s_time))
If len (h) = 1 Then h = "0" & H
Mi = CStr (Minute (s_time))
If len (mi) = 1 Then mi = "0" & mi
s = CStr (second (s_time))
If len (s) = 1 Then s = "0" & S
Select Case N_flag
Case 1
' Yyyy-mm-dd Hh:mm:ss
Format_time = y & "-" & M & "-" & D & "" & H & ":" & Mi & ":" & S
Case 2
' Yyyy-mm-dd
Format_time = y & "-" & M & "-" & D
Case 3
' Hh:mm:ss
Format_time = h & ":" & Mi & ":" & S
Case 4
' YYYY year mm month DD Day
Format_time = y & "Year" & M & "Month" & D & "Day"
Case 5
' YYYYMMDD
Format_time = y & M & D
End Select
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service