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 <item></item>'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 "<pubDate>"& getrfcdate(now()) &"</pubDate>" & vbcrlf
- %>
There you go
2 comments
1 year and 4 months ago
here is a complete ready to use RSS component for classic asp http://www.webdevbros.net/2007/07/01/asp-vbscript-rss-readerwriter-class/
1 year and 4 months ago
Gabru, that's a neat package you got there. I will check it out further for sure! Thanks!
Write a comment
If you want to add your comment on this post, simply fill out the next form:
* Required fields
You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>.
No trackbacks
To notify a mention on this post in your blog, enable automated notification (Options > Discussion in WordPress) or specify this trackback url: http://skeymedia.com/rfc-32-date-formatting-with-classic-asp/trackback/