FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

ASP Tutorial: Converting normal Date into RFC-822 Format Date using ASP

jawahar
4/19/2005 12:27:23 AM, Views: 6705
The following tutorial and code will show how to convert to format a normal Date into RFC-822 Format Date using ASP(VBScript). These are required for various things but in particular they are required format for dates in RSS feeds.

<%
Function return_RFC822_Date(myDate, offset)
   Dim myDay, myDays, myMonth, myYear
   Dim myHours, myMonths, mySeconds

   myDate = CDate(myDate)
   myDay = WeekdayName(Weekday(myDate),true)
   myDays = Day(myDate)
   myMonth = MonthName(Month(myDate), true)
   myYear = Year(myDate)
   myHours = zeroPad(Hour(myDate), 2)
   myMinutes = zeroPad(Minute(myDate), 2)
   mySeconds = zeroPad(Second(myDate), 2)

   return_RFC822_Date = myDay&", "& _
                                  myDays&" "& _
                                  myMonth&" "& _
                                  myYear&" "& _
                                  myHours&":"& _
                                  myMinutes&":"& _
                                  mySeconds&" "& _
                                  offset
End Function
Function zeroPad(m, t)
   zeroPad = String(t-Len(m),"0")&m
End Function
%>


You call return_RFC822_Date with a parsable date (by CDate) and a timezone or offset which complies with RFC822. The function attempts to parse the date value passed to it and it then generates the date in the correct format.

You would call the above functions like so:

<%=return_RFC822_Date("19/03/2003", "GMT")%>
<%=return_RFC822_Date(Now(), "GMT")%>


Output:

Wed, 19 Mar 2003 00:00:00 GMT
Wed, 1 Dec 2004 19:21:03 GMT
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rating Booth
Avg Visitor Rating: Average Visitor Rating is 4.5 out of 5
Number of Ratings : 14 Votes
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
ASP RSS Feed
Most Popular Tutorial
Most Popular Solution
Top Rated
Top Rankers
Overall
1. jawahar (2850)
Yearly -2008
1. jawahar (50)
Expertsforge Sponsors
bnrtop