Share via


DateTimeFormatter.Format Method

Definition

Overloads

Format(DateTime)

Returns a string representation of the provided date and time.

Format(DateTime, String)

Returns a string that represents the given date and time in the given time zone, conforming to the template the formatter is currently using.

Format(DateTime)

Returns a string representation of the provided date and time.

public:
 virtual Platform::String ^ Format(DateTime value) = Format;
winrt::hstring Format(DateTime const& value);
public string Format(System.DateTimeOffset value);
function format(value)
Public Function Format (value As DateTimeOffset) As String

Parameters

value
DateTime DateTimeOffset

The date and time to be formatted.

Returns

String

Platform::String

winrt::hstring

A string that represents the date and time.

Remarks

Note

If your application supports the Japanese calendar, you should validate that it properly handles the May 2019 Japanese era change. See Prepare your application for the Japanese era change for more information.

See also

Applies to

Format(DateTime, String)

Returns a string that represents the given date and time in the given time zone, conforming to the template the formatter is currently using.

public:
 virtual Platform::String ^ Format(DateTime datetime, Platform::String ^ timeZoneId) = Format;
/// [Windows.Foundation.Metadata.Overload("FormatUsingTimeZone")]
winrt::hstring Format(DateTime const& datetime, winrt::hstring const& timeZoneId);
[Windows.Foundation.Metadata.Overload("FormatUsingTimeZone")]
public string Format(System.DateTimeOffset datetime, string timeZoneId);
function format(datetime, timeZoneId)
Public Function Format (datetime As DateTimeOffset, timeZoneId As String) As String

Parameters

datetime
DateTime DateTimeOffset

The date, time, and timezone to be formatted.

timeZoneId
String

Platform::String

winrt::hstring

An identifier from the IANA Time Zone Database that identifies the time zone to use (for example, "Americas/Los_Angeles" for Pacific Time).

Returns

String

Platform::String

winrt::hstring

A string that represents the date, time, and time zone.

Attributes

Remarks

Note

If your application supports the Japanese calendar, you should validate that it properly handles the May 2019 Japanese era change. See Prepare your application for the Japanese era change for more information.

See also

Applies to