Convert Date into User Preference Timezone using timezone abbrevation

95 views Asked by At

i am using momentJS library for timezone conversion logic in javascript. i am getting User Preference Timezone abbreviation value from the web service response. I need to convert date using Timezone abbreviation but it is not working for certain timezone.

 var  Date  = moment(dateObject).tz("CST").format(getDateFormat.defaultDateFormat());

Is there any way to convert a date using Timezone abbreviation in javascript?

Note: Need to convert date using Timezone abbreviation and It should also handle daylight saving time (DST)

Appreciate for your help.

1

There are 1 answers

0
Sohan Soni On

This is not possible with moment library. You will need full timezone name e.g. America/Chicago , while converting the date.

If you use abbreviation, you will get error : Moment Timezone has no data for CST. See http://momentjs.com/timezone/docs/#/data-loading/.