TimeOnly.FromDateTime(DateTime) Method

Definition

Constructs a TimeOnly object from a DateTime representing the time of the day in this DateTime object.

C#
public static TimeOnly FromDateTime(DateTime dateTime);

Parameters

dateTime
DateTime

The DateTime object to extract the time of the day from.

Returns

A TimeOnly object representing time of the day specified in the DateTime object.

Applies to

Product Versions
.NET 6, 7, 8, 9, 10