Please enable Javascript for better experience...
Get browser TimeZone ID through javascript
By Rahul Kumar Jha | Jul 9, 2014 | In Articles | Update: Sep 16, 2014 | Total Views [ 9401 ]
Taged In
(3 Like)
Rate

It happens to me most of the time that I need to find user's local timezone id in my projects. In this article I will show how to get browserl timezone id for user.

Introduction

Now a day we don't create a project marely for one country or one timezone but it can be used from any region in world. User can hit a web page from any part of world and this is the key portion of a website that it can reach to millions of users. And this is why we cannot bound our project to culture specific or timezone specific. So here I will try to show how we can get user's local browser timezone through javascript so that one can use this accordingly.

Code

We can find timezone id very easily for a browser through javascript with two or three lines of code.

<script language="javascript">

function GetUserTimeZoneID(){
    var timezone=String(new Date());
     return timezone.substring(timezone.lastIndexOf('(')+1).replace(')','').trim();
     }


var timezone=GetUserTimeZoneID();
alert('My local timezone id is '+timezone);

</script>

See this was so simple to use. So use it and enjoy. I will come back with another such tips.

Share this

About the Author

Rahul Kumar Jha
Rahul Kumar Jha
Founder, Developer dotnet-concept.com

Public profile: user/profile/99900001


Has working experience in different phases of Software Development Life Cycle (SDLC) in CMS, Gaming, Health Care and Financial Services domain using Agile pattern. Working experience in Design patterns, ASP.NET, MVC, ANGULAR, ANGULAR JS, Windows application, WCF, ADO.NET, SQL Server and Test Driven Development (TDD) environment with JQuery, JavaScript, N-Unit, Entity Frameworks, LINQ, Code Refactoring and Business Objects Models.

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment
 
 
 
 
 
 
Sponsors