Format DateTime value in RFC1123 pattern with "r" flag in CSharp
Description
The following code shows how to format DateTime value in RFC1123 pattern with "r" flag.
Example
using System;/* ww w . j av a2 s .c o m*/
public class MainClass {
public static void Main()
{
DateTime date1 = new DateTime(2008, 4, 10, 6, 30, 0);
DateTimeOffset dateOffset = new DateTimeOffset(date1,
TimeZoneInfo.Local.GetUtcOffset(date1));
Console.WriteLine(date1.ToUniversalTime().ToString("r"));
// Displays Thu, 10 Apr 2008 13:30:00 GMT
Console.WriteLine(dateOffset.ToUniversalTime().ToString("r"));
// Displays Thu, 10 Apr 2008 13:30:00 GMT
}
}
The code above generates the following result.