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("3/28/2024 2:24:21 AM")
It will output Thu, 28 Mar 2024 02:24:21 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("3/28/2024 2:24:21 AM")



%>



               
© 1967 - 2024 Soren Winslow