asp 顯示當前中文時間,日期,月份,英文時間,日期,月份

來源:互聯網
上載者:User

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("Jan","Feb","Mar","Apr","May","Jun","Jul","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&" "&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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.