Essay record

C#: Default to DateTimeOffset over DateTime

Record
Essay / / 1 min read / 93 words
On this page4 sections / +

DISCLOSURE: Some links may be affiliate links. Details

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

Built with CloudSeed Rust