Skip to content

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

@John0King

Description

@John0King

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-localization

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions