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.
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.
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.