ASP read Date single date auto complement 0 function code _ Application Tips

Source: Internet
Author: User
Tags locale
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
%>
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.