Soren Winslow
RSS PubDate Date Formatting Function
As you may already know, RSS feeds need to have their PubDate formatted properly to use. You may also know that most databases do not store a date in the same format as a RSS Data feed requires. This is a quick and easy way format your date into the required proper RSS PubDate.
The function is called RSSDate().
If you call RssDate("11/26/2024 11:53:33 PM")
It will output Tue, 26 Nov 2024 23:53:33 GMT

Here is the code for the RSSDate() function:

<%

      

Function RSSDate(TheDateTime)



   TheDay = Day(TheDateTime)

   DayName = WeekdayName(Weekday(TheDateTime),True)

   TheMonth = MonthName(Month(TheDateTime),True)

   TheYear = Year(TheDateTime)

   TheHour = Hour(TheDateTime)

   TheMinute = Minute(TheDateTime)

   TheSecond = Second(TheDateTime)



   While Len(TheDay) < 2

      TheDay = CStr("0" & TheDay)

   Wend

   While Len(TheHour) < 2

      TheHour = CStr("0" & TheHour)

   Wend

   While Len(TheMinute) < 2

      TheMinute = CStr("0" & TheMinute)

   Wend

   While Len(TheSecond) < 2

      TheSecond = CStr("0" & TheSecond)

   Wend



  RSSDate = DayName & ", " & _

            TheDay & " " & TheMonth & " " & TheYear & " " & _

            TheHour & ":" & TheMinute & ":" & TheSecond & " GMT"



End Function



Response.Write RSSDate("11/26/2024 11:53:33 PM")



%>



               
© 1967 - 2024 Soren Winslow