-
Notifications
You must be signed in to change notification settings - Fork 302
Description
Problem Explained
Currently, we are storingDateTime based on the location of the device the application is hosted on, but we don't take into account that if someone accesses this website from another timezone it doesn't show up properly.
We should store all the DateTime's as DateTime.UtcNow in the database, and convert the time back to a user his local time on request. Therefore we would be able to convert a UTC timestamp back to the user his timezone, so everyone sees a timestamp in their own local format.
I would recommend reading this very interesting article by Shay Rojansky, who is a member of the entity framework team at Microsoft, and lead developer of the PostgreSQL entity framework provider.
For example currently, because I'm using PostgreSQL I had to enable AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);, which results in all the timestamps being converted to UTC now when writing to the Database, but because we are only showing the end user the local saved timezone for me all the timestamps are not converted properly, which is also a problem for people who are outside of the timezone the application is hosted on.
I suggest we start working on a proper conversion for timezones to boost this project in terms of professionalism, and production readiness.
Problem Example
Local console log time:
Website log time:
As you can see my current time was 14:20, but since the DateTime is being saved in UTC the website will show up in UTC 12:20.
As I said earlier this isn't only a problem when using PostgreSQL, but also when someone would be outside of the timezone the application is hosted on, which would make it impossible to use worldwide.

