r/csharp • • 9d ago

Best approach for centralized DateTime handling in ASP.NET MVC 5?

I'm working on an existing application built with ASP.NET MVC 5, Entity Framework 6, SQL Server, and DevExpress/DevExtreme components. We want to implement a centralized approach for storing all dates in UTC and converting them to the appropriate local timezone for display, while also handling date filters and existing database records correctly. Since the application has multiple controllers, services, and grids, we'd like to avoid repeating conversion logic throughout the codebase. What architecture or best practices would you recommend for implementing this consistently, safely, and with minimal changes to the existing application?

16 Upvotes

32 comments sorted by

View all comments

Show parent comment

6

u/r2d2_21 9d ago

If you're already gonna ban DateTime, go all the way and use NodaTime instead.

4

u/wickerandscrap 8d ago

This is the right answer.