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 & "" &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