Soren Winslow 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("5/20/2018 8:51:04 PM")
It will output Sun, 20 May 2018 20:51:04 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("5/20/2018 8:51:04 PM")



%>



               
© 1967 - 2018 Soren Winslow