0

I am getting timezone using Javascript:

var current_date = new Date( );
     var n = current_date.toString(); 
     var arr = n.split("(");
     var result = arr[arr.length-1];
     var result1 = result.replace(")", "");

But in mac it is returning "IST" and in windows it is returning "Indian Standard Time". How can i shorten Indian Standard Time to IST.

Anil Kumar
  • 209
  • 1
  • 4
  • 15
  • Could you show us result of IST and Indian Standard Time.. – sheshadri May 07 '15 at 06:44
  • [Spec](http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.2): "This function returns a String value. **The contents of the String are implementation-dependent**, but are intended to represent the Date in the current time zone in a convenient, human-readable form." (emphasis mine). The best you can do, I think, is take `current_date.getTimezoneOffset()` and map it yourself. Or a simple `replace` if you know for all implementations what you are getting (but possibly you won't catch them all). – Amadan May 07 '15 at 06:44
  • http://postimg.org/image/f7m7u6kib/ - mac. http://postimg.org/image/oxlmvgct3/ - windows. – Anil Kumar May 07 '15 at 07:24

1 Answers1

0

If you want to do the proper mapping, Time Zone Abbreviations – Worldwide List has the list of all the abbreviations and their full name.

I'm not sure what your use case is for the timezone but you'd probably want to be careful as IST also stands for Israel Standard Time and Irish Standard Time.

Daniel Chu
  • 96
  • 2