.NET/Answer Detail

How to get client machine time zone?

28 Points
14 Posts

Hi everyone,

Does anyone know the way to get the client machine time zone?

Total Answered: 2
Total Marked As Answer: 1
Posted On: 13-Oct-2017 06:14
Share:   fb twitter linkedin
I think, JavaScript getTimezoneOffset() Method may help to get timezone
 - Priya  13-Oct-2017 06:18
336 Points
148 Posts
Posted On: 17-Oct-2017 05:02

Use JavaScript getTimezoneOffset() Method.  It will return the timezone difference between UTC and Local Time, in minutes. For example, If your time zone is GMT+2, -120 will be returned.

var d = new Date();
var n = d.getTimezoneOffset();

Note: The returned value is not a constant, because of the practice of using Daylight Saving Time.
Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

34 Points
12 Posts
Marked as answer  
Posted On: 19-Oct-2017 02:20

Do following in client side on page load:

$(document).ready(function () {
    var d = new Date();
    var tZOffset = d.getTimezoneOffset();
        url: '/mytimezone/sendTimezoneOffset',
        data: { timezoneOffset: tZOffset },
        dataType: "json",
        success: function (data) {
        error: ajaxErrorCallBack

On server side calculate the timezone on the basis of offset:

public ActionResult sendTimezoneOffset(double timezoneOffset)
    var zone = TimeZoneInfo.GetSystemTimeZones().FirstOrDefault(x => x.BaseUtcOffset.TotalMinutes == -timezoneOffset);
    string timeZoneId;
    if (zone != null && !string.IsNullOrEmpty(zone.Id))
        timeZoneId = zone.Id;
    return Json(timeZoneId);


Active User (1)

 Log In to Chat