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.
DateTimeOffset
- Date and time
- Offset indicating difference from UTC
Is basically DateTime plus it has awareness of time zones.
DateTime
- Date and time
Conclusion
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.
References
Want more like this?
The best / easiest way to support my work is by subscribing for future updates and sharing with your network.