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("9/25/2017 9:06:47 AM")
It will output Mon, 25 Sep 2017 09:06:47 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("9/25/2017 9:06:47 AM")



%>



               
© 1967 - 2017 Soren Winslow