How to get current user TimeZone in C#

You will need to use both client-side and server-side technologies.

On the client side:
(pick one)

  • This works in most modern browsers:

    Intl.DateTimeFormat().resolvedOptions().timeZone
    
  • There is also jsTimeZoneDetect's jstz.determine(), or Moment-Timezone's moment.tz.guess() function for older browsers.

The result from either will be an IANA time zone identifier, such as America/Los_Angeles. Send that result to the server by any means you like.

On the server side:
(pick one)

  • Using TimeZoneInfo (on Non-Windows systems only):

    TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
    
  • Using TimeZoneConverter (on any OS):

    TimeZoneInfo tzi = TZConvert.GetTimeZoneInfo("America/New_York");
    
  • Using NodaTime (on any OS):

    DateTimeZone tz = DateTimeZoneProviders.Tzdb["America/New_York"];
    
Last updated: 11/15/2020 7:43:52 AM

Latest Updates

© 0 - 2025 - Mike Brind.
All rights reserved.
Contact me at Mike dot Brind at Outlook.com