public static DateTimeOffset ToDateTimeOffset(
this DateTime dateTime
)
DateTimeKind | Result |
---|---|
Local | A DateTimeOffset whose Offset is equal to the Local's UTC offset as of dateTime. |
Utc | A DateTimeOffset whose Offset is equal to the Zero. |
Unspecified | A DateTimeOffset whose Offset is equal to the Zero, and whose value is equal to dateTime.ToUniversalTime following the Base Class Library's rules for determining the value's actual time zone. |
var testDate = new DateTime(2022, 11, 18, 0, 0, 0, DateTimeKind.Utc);
? testDate.ToDateTimeOffset();
// Result: 2022-11-18T00:00:00