HttpResponseHeaderCollection.Date | date property

Applies to Windows and Windows Phone

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

Syntax


var date = httpResponseHeaderCollection.date;
httpResponseHeaderCollection.date = date;

Property value

Type: IReference<DateTime> [JavaScript/C++] | System.Nullable<DateTime> [.NET]

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 Date 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 DateTime.UniversalTime value has the same granularity as a FILETIME 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());
    }


Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Web.Http.Headers
Windows::Web::Http::Headers [C++]

Metadata

Windows.winmd

See also

HttpResponseHeaderCollection
HttpResponseMessage
HttpResponseMessage.Headers
Windows.Foundation.DateTime

 

 

Show:
© 2014 Microsoft