-2

Is it a way to get TimeZone Name or ID in C# just knowing offset fetched from Javascript in browser?

Vnuuk
  • 6,177
  • 12
  • 40
  • 53
  • 3
    The same offset can be located in many different time zones, so no. – Igor Feb 27 '17 at 18:25
  • In short, no. But you can use `jsTimeZoneDetect` or `moment.tz.guess()` to guess the IANA time zone id, then map it to a Windows time zone id. More in the "get name of time zone" dup answer. – Matt Johnson-Pint Feb 28 '17 at 00:10

1 Answers1

0

Here is the best information on extracting the timezone information in JavaScript:

https://stackoverflow.com/a/15304657/5258056

It gives you how to get every piece of the timezone you'll need. That way you can just send the information back to C# that you need and not just the offset. It's impossible in C#.

See: https://stackoverflow.com/a/1274752/5258056

Edit 1: After reading a comment from @Mike McCaughan:

I now see that it is impossible to do even from Javascript due to Daylight Savings because There is no standard saying browsers must return that information from the toString method, as the comments on the question indicate. Thanks Mike.

Also, from Getting the client's timezone in JavaScript:

The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned. Daylight savings time prevents this value from being a constant even for a given locale.

Community
  • 1
  • 1
Kaden.Goodell
  • 162
  • 1
  • 8
  • 2
    Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. Additionally, the answer specified in that link is a bad way of getting the time zone. There is no standard saying browsers must return that information from the `toString` method, as the comments on the question indicate. – Heretic Monkey Feb 27 '17 at 18:29