DateTime.Now equivalent for TimeOnly and DateOnly?

You can use .FromDateTime() method,

To get current date only:

var dateNow = DateOnly.FromDateTime(DateTime.Now);

To get current time only:

var timeNow = TimeOnly.FromDateTime(DateTime.Now);

For more details, you can go through Github issue. There are several good comments which explains, why .Now property is not introduced to DateOnly and TimeOnly

Why .Today, .Now and UtcNow properties are not introduced to DateOnly?

  • From @tarekgh comment, dotnet community is trying to keep DateOnly not relate to time zones

Next comment from @tarekgh, explained further complexity if they introduce these properties to the DateOnly.


After reading github thread and couple of other documentations, I feel like introducing DateOnly and TimeOnly structs are just to decouple the DateTime.

This decoupling of date and time will help us in future to perform individual calculations on Date and Time separately.

This will help us to design our model classes precisely and at granular level.

Leave a Comment