Skip to content Skip to sidebar Skip to footer

Incorrect Timezone Name In Javascript Only In Ie

I am using the below mentioned code for getting the timezone name/id in the clients timezone. Using the below code I get EDT for United state clients but now when I try it in India

Solution 1:

Quoting MDN:

The toTimeString() method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString() for Date objects, as the format is implementation-dependent; simple string slicing approaches may not produce consistent results across multiple engines.

I suggest you try using .toTimeString():

(newDate()).toTimeString().match(/\(([^\)]+)\)/)[1]

I believe that should give you what you want.

Post a Comment for "Incorrect Timezone Name In Javascript Only In Ie"