ASP displays current Chinese time, date, month, English time, date, month

Source: Internet
Author: User
Tags datetime

Public Function datetostr (datetime,showtype)
Dim Datemonth,dateday,datehour,dateminute,dateweek,datesecond
Dim Fullweekday,shortweekday,fullmonth,shortmonth,timezone1,timezone2
timezone1= "+0800"
Timezone2= "+08:00"
Fullweekday=array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
Shortweekday=array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
Fullmonth=array ("January", "February", "March", "April", "may", "June", "July", "August", "September", "October", " November "," December ")
Shortmonth=array ("The", "Feb", "Mar", "APR", "may", "June", "may", "Aug", "Sep", "Oct", "Nov", "Dec")

Datemonth=month (DateTime)
Dateday=day (DateTime)
Datehour=hour (DateTime)
Dateminute=minute (DateTime)
Dateweek=weekday (DateTime)
Datesecond=second (DateTime)
If Len (datemonth) <2 Then datemonth= "0" &datemonth
If Len (dateday) <2 Then dateday= "0" &dateday
If Len (dateminute) <2 Then dateminute= "0" &dateminute
Select Case ShowType
Case "Y-m-d"
Datetostr=year (DateTime) & "-&DateMonth&"-"&dateday
Case "Y-m-d h:i A
Dim DATEAMPM
If datehour>12 Then
Datehour=datehour-12
Dateampm= "PM"
Else
Datehour=datehour
Dateampm= "AM"
End If
If Len (datehour) <2 Then datehour= "0" &datehour
Datetostr=year (DateTime) & "-" &DateMonth& "-" &DateDay& "" &DateHour& ":" &dateminute & "" &AMP;DATEAMPM
Case "Y-m-d h:i:s"
If Len (datehour) <2 Then datehour= "0" &datehour
If Len (datesecond) <2 Then datesecond= "0" &datesecond
Datetostr=year (DateTime) & "-" &DateMonth& "-" &DateDay& "" &DateHour& ":" &dateminute & ":" &datesecond
Case "Ymdhis"
Datesecond=second (DateTime)
If Len (datehour) <2 Then datehour= "0" &datehour
If Len (datesecond) <2 Then datesecond= "0" &datesecond
Datetostr=year (DateTime) &datemonth&dateday&datehour&dateminute&datesecond
Case "YM"
Datetostr=right (Year (DateTime), 2) &datemonth
Case "D"
Datetostr=dateday
Case "YMD"
Datetostr=right (Year (DateTime), 4) &datemonth&dateday
Case "MDY"
Dim Dayend
Select Case Dateday
Case 1
Dayend= "St"
Case 2
dayend= "nd"
Case 3
dayend= "RD"
Case Else
dayend= "TH"
End Select
Datetostr=fullmonth (DateMonth-1) & "" &DateDay&DayEnd& "&right (Year (DateTime), 4)
Case "W,d m y h:i:s"
Datesecond=second (DateTime)
If Len (datehour) <2 Then datehour= "0" &datehour
If Len (datesecond) <2 Then datesecond= "0" &datesecond
Datetostr=shortweekday (DateWeek-1) & "," &DateDay& "" & Left (Fullmonth (DateMonth-1), 3) &right ( Year (DateTime), 4 & "" &DateHour& ":" &DateMinute& ":" &DateSecond& "" &timezone1
Case "Y-m-dth:i:s"
If Len (datehour) <2 Then datehour= "0" &datehour
If Len (datesecond) <2 Then datesecond= "0" &datesecond
Datetostr=year (DateTime) & "-" &DateMonth& "-" &DateDay& "T" &DateHour& ":" &dateminute & ":" &datesecond&timezone2
Case Else
If Len (datehour) <2 Then datehour= "0" &datehour
Datetostr=year (DateTime) & "-" &DateMonth& "-" &DateDay& "" &DateHour& ":" &dateminute
End Select
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.