<%
'Function: Date Formatting Function
'Source: http://jorkin.reallydo.com/article.asp? Id = 477
Function formatdate (sdatetime, sreallydo)
Dim sjorkin
Sjorkin = getlocale ()
If not isdate (sdatetime) Then sdatetime = now ()
Sdatetime = cdate (sdatetime)
Select case ucase (sreallydo &"")
Case "0", "1", "2", "3", "4"
Formatdate = formatdatetime (sdatetime, sreallydo)
Case "00"
Formatdate = formatdate (sdatetime, "YYYY-MM-DD hh: mm: SS ")
Case "01"
FormatDate = FormatDate (sDateTime, "mm dd, YYYY ")
Case "02"
FormatDate = FormatDate (sDateTime, "YYYY-MM-DD ")
Case "03"
FormatDate = FormatDate (sDateTime, "hh: mm: ss ")
Case "04"
FormatDate = FormatDate (sDateTime, "hh: mm ")
Case "ISO8601", "GOOGLE", "SITEMAP" '// ISO8601 format, generally used for GoogleSiteMap, "+" is the time zone.
FormatDate = FormatDate (sDateTime, "YYYY-MM-DDThh: mm: ss.000 + 08:00 ")
Case "RFC822", "RSS", "FEED" '// RFC822 format, generally used for RSS, "+ 0800" is the time zone.
SetLocale ("en-gb ")
FormatDate = FormatDate (sDateTime, "ew, DD eMM YYYY hh: mm: ss + 0800 ")
SetLocale (sJorkin)
Case "RND", "RAND", "RANDOMIZE" '// random string
Randomize
SJorkin = Rnd ()
Formatdate = formatdate (sdatetime, "yyyymmddhhmmss ")&_
Fix (9*10 ^ 6-1) * sjorkin) + 10 ^ 6
Case else
Formatdate = sreallydo
Formatdate = Replace (formatdate, "YYYY", year (sdatetime ))
Formatdate = Replace (formatdate, "DD", right ("0" & Day (sdatetime), 2 ))
Formatdate = Replace (formatdate, "hh", right ("0" & hour (sdatetime), 2 ))
FormatDate = Replace (FormatDate, "mm", Right ("0" & Minute (sDateTime), 2 ))
FormatDate = Replace (FormatDate, "ss", Right ("0" & Second (sDateTime), 2 ))
FormatDate = Replace (FormatDate, "YY", Right (Year (sDateTime), 2 ))
FormatDate = Replace (FormatDate, "D", Day (sDateTime ))
FormatDate = Replace (FormatDate, "h", Hour (sDateTime ))
FormatDate = Replace (FormatDate, "m", Minute (sDateTime ))
FormatDate = Replace (FormatDate, "s", Second (sDateTime ))
If InStr (1, FormatDate, "EW", 1)> 0 Then
SetLocale ("en-gb ")
FormatDate = Replace (FormatDate, "EW", UCase (WeekdayName (Weekday (sDateTime), False )))
FormatDate = Replace (FormatDate, "eW", WeekdayName (Weekday (sDateTime), False ))
FormatDate = Replace (FormatDate, "Ew", UCase (WeekdayName (Weekday (sDateTime), True )))
Formatdate = Replace (formatdate, "ew", weekdayname (weekday (sdatetime), true ))
Setlocale (sjorkin)
Else
Formatdate = Replace (formatdate, "W", weekdayname (weekday (sdatetime), false ))
Formatdate = Replace (formatdate, "W", weekdayname (weekday (sdatetime), true ))
End if
If InStr (1, FormatDate, "EMM", 1)> 0 Then
SetLocale ("en-gb ")
FormatDate = Replace (FormatDate, "EMM", MonthName (Month (sDateTime), False ))
FormatDate = Replace (FormatDate, "eMM", MonthName (Month (sDateTime), True ))
SetLocale (sJorkin)
Else
FormatDate = Replace (FormatDate, "MM", Right ("0" & Month (sDateTime), 2 ))
FormatDate = Replace (FormatDate, "M", Month (sDateTime ))
End If
End Select
End Function
%>
<%
'Format the date in ISO8601 format.
Response. Write (FormatDate ("08:03:06", "SITEMAP "))
'Format the date in RFC822 format
Response. Write (FormatDate ("08:03:06", "RSS "))
'Format the date as (English week, English month/day/year)
Response. Write (FormatDate (Now (), "eW, EMM/DD/YYYY "))
'Generate a string of random numbers by year, month, day, hour, minute, second
Response. Write (FormatDate (Now (), "RND "))
%>
Source: http://Jorkin.Reallydo.Com/default.asp? Id = 477