'============================================================ ' AUTHOR: © Terje Hauger ' HOME: www.u229.no/stuff/snippets/TimeStamps.asp ' CREATED: February 2006 '============================================================ ' COMMENT: This code lets you create valid timestamps for RSS 2.0 and Atom 1.0. ' Your web server must be set up with correct time zone and daylight savings time (if required). '============================================================ SAVE THIS AS GETSERVERGMT.ASP: <%@language="jscript"%> <% var od = new Date(); var nd = od.toGMTString(); Session("ServerGMT") = nd; %> '------------------------------------------------------------------------------------------------------------ ' Comment: Create a valid RFC822 timestamp for RSS 2.0. Example: Wed, 1 Feb 2006 15:00:00 GMT '------------------------------------------------------------------------------------------------------------ Function CreateRSSTime() Server.Execute "GetServerGMT.asp" CreateRSSTime = Replace(Session("ServerGMT"), "UTC", "GMT") End Function '------------------------------------------------------------------------------------------------------------ ' Comment: Create a valid RFC3339 timestamp for Atom 1.0. Example: 2006-04-12T23:20:50Z '------------------------------------------------------------------------------------------------------------ Public Function CreateAtomTime() Dim sYear, sMonth, sDay, sHour, sMinute, sSecond Dim arrUTC, arrUTCTime '// Use JScript to get the current UTC (GMT) time stamp and store it in Session("ServerGMT") '// Session("ServerGMT") should have this format: Wed, 1 Feb 2006 15:00:00 UTC Server.Execute "GetServerGMT.asp" arrUTC = Split(Session("ServerGMT"), Chr(32)) arrUTCTime = Split(arrUTC(4), ":") sYear = arrUTC(3) sMonth = Right("0" & ConvertUTCMonth(arrUTC(2)), 2) sDay = Right("0" & arrUTC(1), 2) sHour = arrUTCTime(0) sMinute = arrUTCTime(1) sSecond = arrUTCTime(2) CreateAtomTime = sYear & "-" & sMonth & "-" & sDay & "T" & sHour & ":" & sMinute & ":" & sSecond & "Z" End Function '------------------------------------------------------------------------------------------------------------ ' Comment: A helper routine for CreateAtomTime. '------------------------------------------------------------------------------------------------------------ Private Function ConvertUTCMonth(sMonth) Dim sOut Select Case UCase(sMonth) Case "JAN" sOut = 1 Case "FEB" sOut = 2 Case "MAR" sOut = 3 Case "APR" sOut = 4 Case "MAY" sOut = 5 Case "JUN" sOut = 6 Case "JUL" sOut = 7 Case "AUG" sOut = 8 Case "SEP" sOut = 9 Case "OCT" sOut = 10 Case "NOV" sOut = 11 Case "DEC" sOut = 12 Case Else End Select ConvertUTCMonth = sOut End Function