ASP format Time function

Source: Internet
Author: User
Tags time and date

ASP Tutorial Format Time function

' This function can be based on the user given the time date, time, minutes, etc., as long as the user given different style parameters can display different styles of time and date.

function Formattime (Testtime,style)

Dim n,y,r,s,f,m

n = year (testtime)

y = month (testtime)

R = Day (testtime)

s = Hour (testtime)

f = Minute (Testtime)

M = Second (testtime)

If Len (n) = 2 then n = "M" & N

If Len (y) = 1 then y = "0" & Y

If Len (r) = 1 Then R = "0" & R

If Len (s) = 1 then s = "0" & S

If Len (f) = 1 then f = "0" & F

If Len (m) = 1 Then m = "0" & M

Nn=right (n,2)

If style = 1 Then

Formattime = "" & N & "Year" & Y & "month" & R & "Day" & S & "Time"

ElseIf style = 2 Then

Formattime = R & "Day" & S & ": & F &": "& M

ElseIf style = 3 Then

Formattime = N & "year" & Y & "month" & R & "Day"

ElseIf style = 4 Then

Formattime = N & "-" & Y & "-" & R & "" & S & ":" & F

ElseIf style = 5 Then

Formattime = y & "-" & R & "" & S & ":" & F

ElseIf style = 6 Then

Formattime = N & "year" & Y & "month" & R & "Day" & S & ":" & F

ElseIf style = 7 Then

Formattime = N & Y & R & S & F & M

ElseIf style = 8 Then

Formattime = N & "-" & Y & "-" & R

ElseIf style = 9 Then

Formattime = N & "/" & Y & "/" & R

End If

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.