discussion of TimeZone handing in asp.net core‘s Server side rendered content
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
## 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.
Contributor guide
Assessment
This issue has not been assessed yet.