0

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?

  • Does this answer your question? [Can I get the browser time zone in ASP.NET or do I have to rely on JS operations to retrieve the information?](https://stackoverflow.com/questions/2853474/can-i-get-the-browser-time-zone-in-asp-net-or-do-i-have-to-rely-on-js-operations) – Martheen Feb 21 '21 at 07:00

1 Answers1

0

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.

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61