question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

discussion of TimeZone handing in asp.net core‘s Server side rendered content

See original GitHub issue

question:

  1. how do we handle different timezone on the server (mvc/razor pages) and for multiple region site ?
  2. how time be edit/update in en-us region ? (I’m in China, and only have 1 time, BeiJing Time +8)

background

today, when we using Angular/React/Vue to build a system, we can take advantage of the browser and client computer’s timezone. and Date is always local to us, so there are no problem for us to edit and read the time.

but what about a MVC site ? now MVC bind time default to UTC time (that make sqlserver store +0 time), and Mysql will store UTC time any way , and we do not know the client’s timezone on the server, so how we render the DateTimeOffset and DateTime ?

My opinion

  1. we should have RequestTimezone concept, and a middleware to set and get, and InputTaghelper should use that.
  2. A timezone map of country, there are only a few country have multiple timezone, (US , Russian,Canada, Australia )

explain 1 : we can use a small javascript to detect the timezone of browser and set a cookie , and RequestTimeZoneMiddleware read this cookie and set IRequestTimeZone.Current explain 2: direct get a timezone from culture and set it to IRequestTimeZone.Current only if the Current is null.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

0reactions
John0Kingcommented, Feb 21, 2022

@mkArtakMSFT any progresson this? and how you resolve the “date picker” and input-taghelper + “model binding” issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change time zone for an asp.net application
The only way you have is to change the timezone of your server or rewrite all of your code. The best practice is...
Read more >
[Solved] work on different time zone
Client side means the side of our client of this app,not the web programming server-client's client.) We have an customer support web app...
Read more >
Glitchy behavior server-side rendering dates when ...
I have a relatively simple web app that server-side renders dates some pages. Now I have noticed that in production when I refresh...
Read more >
Back to Basics: UTC and TimeZones in .NET Web Apps
Storing dates in persistent storage using UTC dates is a widely accepted best practice. But it's surprisingly complex using date data ...
Read more >
Convert DateTime to user's time zone with server-side Blazor
Let's see how we can get the user's time zone and change the date accordingly. To get the current time zone you need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found