C#: Default to DateTimeOffset over DateTime

Date: 2020-11-30 | csharp | date | time |

Note to self: Default to using DateTimeOffset for dates rather than DateTime.


  • Date and time
  • Offset indicating difference from UTC

Is basically DateTime plus it has awareness of time zones.


  • Date and time


DateTimeOffset is typically what I'll want to use. It does everything DateTime does plus has some additional data on time zones. This makes it easier to do date arithmetic after the fact if time zones need to be taken into account.


Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.