devbox@COMPUTEC The Computec development blog

3May/101

UDF for RFC822 date

This might be useful if you wish to create RFC-822 type date strings from ColdFusion date variables.GetHttpTimeString() will do something similar, but would always use GMT as timezone. If you want to use the timezone configured on your server, you'll need this:

<cffunction name="rfc822date" output="no" returntype="string">
  <cfargument name="dtDate" type="date" required="no" default="#now()#">
  <cfscript>
   var strReturn = DateFormat(arguments.dtDate, "ddd, dd mmm yyyy");
   strReturn &= TimeFormat(arguments.dtDate, " HH:mm:ss");
   strReturn &= ' ' & NumberFormat(GetTimeZoneInfo().utcHourOffset*-1,'+00');
   strReturn &= NumberFormat(GetTimeZoneInfo().utcMinuteOffset,'00');
   return strReturn;
  </cfscript>
</cffunction>

RFC822 dates are needed in RSS feeds, among others.

Comments (1) Trackbacks (0)
  1. Handy piece of code. Thanks for sharing.


Leave a comment

(required)

No trackbacks yet.