user11469175
user11469175

Reputation:

How to Show Local Time Zone in .NET Core

I am trying to show Local Time Zone for each user login from there system by using following code:

localStorage.localTimezone = TimeZoneInfo.Local.StandardName;

Its Working proper for me on my local. I checked many times by changing time zone on my local project.But, after code publish on server it only showing UTC Time Zone for each user while others have IST and PST Time Zone. Because, My server has set to UTC Time Zone. Can someone help me to short out this problem on server without changing time zone?

Upvotes: 0

Views: 2884

Answers (1)

Athanasios Kataras
Athanasios Kataras

Reputation: 26362

To understand the issue, you'll need to think about where the code is executed.

  1. User requests login page from the browser
  2. User enters credentials
  3. Request is made to your server
  4. The localStorage.localTimezone = TimeZoneInfo.Local.StandardName; code is executed on the server
  5. The server creates a response containing the time

Your only choice is to get the timezone from the browser How can I get the timezone name in JavaScript? and send it to your backend.

Upvotes: 0

Related Questions