HttpResponseHeaderCollection.Date Property

Definition

Gets or sets the DateTime object that represents the value of a Date HTTP header on an HTTP response.

public:
 property IReference<DateTime> ^ Date { IReference<DateTime> ^ get(); void set(IReference<DateTime> ^ value); };
IReference<DateTime> Date();

void Date(IReference<DateTime> value);
public System.Nullable<System.DateTimeOffset> Date { get; set; }
var iReference = httpResponseHeaderCollection.date;
httpResponseHeaderCollection.date = iReference;
Public Property Date As Nullable(Of DateTimeOffset)

Property Value

The object that represents the value of a Date HTTP header on an HTTP request. A null value means that the header is absent.

Remarks

The Date property represents the value of a Date HTTP header on an HTTP response. The Date header is the date and time the message was sent.

Javascript and .NET languages do not use the DateTime object directly. In Javascript a DateTime is projected as a object, and in .NET it is projected as a System.DateTimeOffset. Each language transparently handles the conversion to the granularity and date ranges for the respective language.

In C++, a value has the same granularity as a and supports the date ranges required by Javascript and .NET.

For more detailed information, see the Windows.Foundation.DateTime structure.

The following sample code shows a method to get and set the Date header on an HttpResponseMessage object using the Date property on the HttpResponseHeaderCollection object.

public void DemonstrateHeaderResponseDate() {
    var response = new HttpResponseMessage();

    // Set the header with a strong type.
    response.Headers.Date = DateTimeOffset.UtcNow;

    // Get the strong type out
    System.Diagnostics.Debug.WriteLine("Date value in ticks: {0}", response.Headers.Date.Value.Ticks);

    // The ToString() is useful for diagnostics, too.
    System.Diagnostics.Debug.WriteLine("The Date ToString() results: {0}", response.Headers.Date.ToString());
}

Applies to

See also