How do I convert a date to a HTTP-formatted date in .Net / C#
How does one convert a .Net DateTime into a valid HTTP-formatted date string?
Dates can be converted to HTTP valid dates (RFC 1123) by using the "r" format string in .Net. HTTP dates need to be GMT / not offset - this can be done using the ToUniversalTime() method.
So, in C# for example:
string HttpDate = SomeDate.ToUniversalTime().ToString("r");
Right now, that produces HttpDate = "Sat, 16 Aug 2008 10:38:39 GMT"
See Standard Date and Time Format Strings for a list of .Net standard date & time format strings.
See Protocol Parameters for the HTTP date specification, and background to other valid (but dated) RFC types for HTTP dates.