-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
question:
- how do we handle different timezone on the server (mvc/razor pages) and for multiple region site ?
- 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
- we should have
RequestTimezone
concept, and a middleware to set and get, andInputTaghelper
should use that. - 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.