who can write a function to get clients Time zone,return value like:EDT
EST
IST
and so on

- 3,502
- 6
- 38
- 53
-
http://stackoverflow.com/questions/6939685/get-client-time-zone-from-browser May be a duplicate? – Sandeep Nair Apr 24 '12 at 13:30
-
You really don't want abbreviations like that. If you get CST, is it China Standard Time (UTC + 8), or Cuba Standard Time (UTC - 5)? – Dagg Nabbit Apr 24 '12 at 13:33
7 Answers
toTimeString()
method give time with the timezone name try out below...
var d=new Date();
var n=d.toTimeString();
ouput
03:41:07 GMT+0800 (PHT) or 09:43:01 EDT
or
Check : Automatic Timezone Detection Using JavaScript
download jstz.min.js and add a function to your html page
<script language="javascript">
function getTimezoneName() {
timezone = jstz.determine_timezone()
return timezone.name();
}
</script>

- 6,579
- 7
- 67
- 92

- 175,020
- 35
- 237
- 263
Use the Date().getTimezoneOffset() function and then build a hash table from this URL timeanddate to relate it to if you want to use the time zone value.

- 6,579
- 7
- 67
- 92

- 1,061
- 1
- 12
- 17
If you look at the result of calling the toString
method of a Date object, you'll get a value that's something like "Tue Apr 24 2012 23:30:54 GMT+1000 (AUS Eastern Standard Time)". This will depend on what your system locale is set to.
From there you can match each capital letter within the parentheses.
var paren = new Date().toString().match(/\(.+\)/);
return paren ? paren[0].match(/([A-Z])/g).join("") : "";
The catch is that not every browser will include the parenthesised values.
If you're targeting Firefox with a known Java plugin, you can also exploit the java
object in Javascript to create a new TimeZone (java.util.TimeZone) object based on a name (eg. "America/Los_Angeles"), then call the getDisplayName
method to give you the name.

- 1,148
- 1
- 13
- 20
-
Unfortunately I get "Thu Sep 11 2014 11:29:07 GMT+1000 (EST)" when I use new Date().toString(); in Australia in Chrome. This is confusing due to the US EST time zone GMT-0400. – Chris Gunawardena Sep 11 '14 at 01:32
Use jstz to get the timezone name:
jstz.determine().name();
It returns timezone names (like 'America/New York'
) which you can then use with moment.js
etc.
An offset (eg from a js Date
object) is not enough, because it does not carry the additional DST information (you won't know whether the time needs to be adjusted for Daylight Savings and when).

- 3,158
- 2
- 29
- 30
- get client time zone in javascript
- output from -12 : +12
you can modify the output by change on this line
-Math.round(a/60)+':'+-(a%60);
Like-Math.round(a/60);
you get //+2var a = new Date().getTimezoneOffset(); var res = -Math.round(a/60)+':'+-(a%60); res = res < 0 ?res : '+'+res; console.log(res);

- 9,980
- 9
- 41
- 53

- 2,746
- 23
- 21
If you don't mind getting the full name, try this:
let timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; // like "America/Chicago"
(Oh, you asked 11 years ago. My bad. ;-)

- 1,849
- 20
- 13
This is the perfect answer to get full timezone of country-
var a = new Date($.now());
var regExp = /\(([^)]+)\)/;`enter code here`
var matches = regExp.exec(a);
alert(matches[1]);
this alert will give you output like indian standard time,american standard time,african standard time:
//$("#timezone option:contains(" + matches[1] + ")").attr('selected', 'selected');

- 47,830
- 31
- 106
- 135