Monday, December 26, 2011

vbscript rfc822 date

Function RFC822(d)
    ' Date: Mon, 26 Dec 2011 12:58:33 GMT
    Dim a, b
    a = Split("Mon,Tue,Wed,Thu,Fri,Sat,Sun", ",")
    b = Split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec", ",")
    Dim tmp
    tmp = a(Weekday(d, 2) - 1) & ", " & _
        Right("0" & Day(d), 2) & " " & _
        b(Month(d) - 1) & " " & _
        Year(d) & " " & _
        Right("0" & Hour(d), 2) & ":" & _
        Right("0" & Minute(d), 2) & ":" & _
        Right("0" & Second(d), 2) & " GMT"
    RFC822 = tmp
End Function
 
' usage: Response.AddHeader "Last-Modified", RFC822(dateadd("h",-1,now))