Format the time display function by the specified parameter in ASP.
Source: Internet
Author: User
<%
'Function: format the display time according to the specified parameter.
'Numformat = 1: convert the time to yyyy-mm-dd hh: nn format.
'Numformat = 2: convert the time to yyyy-mm-dd format.
'Numformat = 3: convert the time to hh: nn format.
'Numformat = 4: convert the time to the nn format of hh on mm dd, yyyy.
'Numformat = 5: convert the time format to yyyy mm dd.
'Numformat = 6: converts the time to the nn format when hh is used.
'Numformat = 7: convert the time format to yyyy, mm, dd, dd, and Day ×.
'Numformat = 8: convert the time to yymmdd format.
'Numformat = 9: convert the time to mmdd format.
Function formatdate (shijian, numformat)
Dim ystr, mstr, dstr, hstr, nstr 'variable meanings: Year string, month string, Day string, hour string, minute string
If isnull (shijian) then
Numformat = 0
Else
Ystr = DatePart ("yyyy", shijian)
If DatePart ("m", shijian)> 9 then
Mstr = DatePart ("m", shijian)
Else
Mstr = "0" & DatePart ("m", shijian)
End if
If DatePart ("d", shijian)> 9 then
Dstr = DatePart ("d", shijian)
Else
Dstr = "0" & DatePart ("d", shijian)
End if
If DatePart ("h", shijian)> 9 then
Hstr = DatePart ("h", shijian)
Else
Hstr = "0" & DatePart ("h", shijian)
End if
If DatePart ("n", shijian)> 9 then
Nstr = DatePart ("n", shijian)
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.