Formatting DateTime value in .NET to RFC-822 format

Posted by Max | Posted in .net | Posted on 02-02-2009

0

If you need to generate a datetime value for RSS feed you need to use RFC-822 format for dates. You can do it the following Extension method:

public static string ToRFC822String(this DateTime date)
{
    return date.ToString("ddd, dd MMM yyyy HH:mm:ss ") +
        date.ToString("zzzz").Replace(":", String.Empty);
}

Write a comment