fillzero function: If the two dates, month and day, are odd numbers, add 0 in front. For example, the general format of March 3, 2011 is that 2011-3-3 is converted into a format such as 2011-03-03 through a function. Copy the 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 the code code as follows:
response year(now)&month(now)&day(now) result:201116
response year(now)&fillzero(month(now))&fillzero(day(now)) Display results:20110106
How to control the display of long date format and short date format:
Short Date:FORMATDATETIME(DATE,vbShortDate)
Long Date:FORMATDATETIME(DATE,vbLongDate)
When displaying a date based on the UK (US) locale, the date is displayed in the following format:
Short Date:7/9/97
Long Date:Wednesday,July 09,1997
Note: The short date format appears 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 displaying the time in the United Kingdom (United States) locale, the time is formatted as follows:
Short Time:03:20
Long Time:3:20:08 AM
Copy the 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, add zero to one digit 2003-1-2 --> 2003-01-02
function ConvertDate(tDate)
ttt=tDate
if isdate(tDate) then
ttt=year(tDate) & - & FillZero(month(tDate)) & - & FillZero(day(tDate))
end if
ConvertDate=ttt
end function
'Enter a date and time string, convert it to four adult digits, and the other two digits to a new date and time string
function ConvertDateTime(tDateTime)
ttt=tDateTime
if isdate(tDateTime) then
ttt=year(tDateTime) & - & FillZero(month(tDateTime)) & - & FillZero(day(tDateTime)) & & FillZero(cstr(hour(tDateTime))) & : & FillZero(cstr(minute(tDateTime)) ) & : & FillZero(cstr(second(tDateTime)))
end if
ConvertDateTime=ttt
end function
%>