Copy Code code as follows:
Public function Fillzero (L1)
If Len (L1) =1 Then
fillzero= "0" &l1
Else
Fillzero=l1
End If
End Function
Usage examples:
Copy Code code as follows:
Response year (now) &month (now) &day results: 201116
Response year (now) &fillzero (month) &fillzero (now) shows results: 20110106
How to control the display of long date formats and short date formats:
Short Date:formatdatetime (date,vbshortdate)
Long Date:formatdatetime (date,vblongdate)
When the date is displayed according to the British (United States) locale, the date is displayed in the following format:
Short date:7/9/97
Long date:wednesday,july 09,1997
Note: The display of the short date format is exactly the same as without any formatting. By default, dates are displayed in short date format.
How to use the FormatDateTime () function to manipulate time:
Short Time:formatdatetime (time,vbshorttime)
Long Time:formatdatetime (Time,vblongtime)
When the time is displayed in the British (United States) locale, the format of the time is as follows:
Short time:03:20
Long time:3:20:08 AM
Copy Code code as follows:
<%
function Fillzero (str)
Ttt=str
If Len (str) =1 then
ttt= "0" & Str
End If
fillzero=ttt
End Function
' conversion date, one to complement zero 2003-1-2--> 2003-01-02
function convertdate (tdate)
Ttt=tdate
If IsDate (tdate) then
Ttt=year (tdate) & "-" & Fillzero (Mo Nth (tdate)) & "-" & Fillzero (Day (tdate))
End If
convertdate=ttt
End Function
' Enter a date-time string, convert Adult four-bit, other two-bit new date-time series
function Convertdatetime (tdatetime)
Ttt=tdatetime
If IsDate (tdatetime) then
ttt= Year (Tdatetime) & "-" & Fillzero (Month (tdatetime)) & "-" & Fillzero (Day (tdatetime)) & "" & Fillze Ro (CStr (Hour (tdatetime)) & ":" & Fillzero (CStr (Minute (tdatetime)) & ":" & Fillzero (CStr ( tdatetime))
End If
convertdatetime=ttt
End Function
%>