RFC-32 Date Formatting with Classic ASP

Tonight I was working on an RSS package for a client of mine. Having dealt with RSS feeds in the past, I figured it wouldn’t be a big deal. However, my experience with them has always been on the ‘receiving’ end of it, imploding out the ‘s and making sense of the xml.

For the most part, setting up the RSS2.0 feed was pretty straight forward. The one thing that took a little time to manipulate was the RFC-32 date/time formatting that RSS Feeds require in order to validate. And we all know how important validation is 🙂

So, I came up with a simple little function to help you out and save you some time in your own Classic ASP RSS feeds.

< % Function getrfcdate(mydate) 'format date in rfc-32 'format: Wed, 02 Oct 2002 08:00:00 EST If Hour(mydate)< 10 Then myhour = "0" & Hour(mydate) Else myhour = Hour(mydate) End If If minute(mydate)< 10 Then myminute = "0" & minute(mydate) Else myminute = minute(mydate) End If If second(mydate)< 10 Then mysecond = "0" & second(mydate) Else mysecond = second(mydate) End If If day(mydate)< 10 Then myday = "0" & day(mydate) Else myday = day(mydate) End If mymonth = monthName(Month(mydate),true) myyear = Year(mydate) dayname = WeekdayName(Weekday(mydate),true) mydate = dayname & ", " & myday & " " & mymonth & " " & myyear & " " & myhour & ":" & myminute & ":" & mysecond & " EST" getrfcdate = mydate End Function %>

To call it, simply pass in a normal date/time string, such as now() or a getdate() recordset variable return from a sql query:

< % response.write ""& getrfcdate(now()) &"" & vbcrlf

There you go 🙂

This entry was posted in Programming. Bookmark the permalink.

3 Responses to RFC-32 Date Formatting with Classic ASP

  1. gabru says:

    here is a complete ready to use RSS component for classic asp http://www.webdevbros.net/2007/07/01/asp-vbscript-rss-readerwriter-class/

  2. Gabru, that’s a neat package you got there. I will check it out further for sure! Thanks!

  3. Madhan says:

    Thanks Gabru the code work’s great

Leave a Reply

Your email address will not be published. Required fields are marked *