Set Specific Time In Specific Timezone Using Momentjs
Solution 1:
Your script is a bit convoluted, but it does seem to work in the fiddle. At least, I don't get an error in Google Chrome. Other browsers may vary.
However, it's not going to always produce the correct results. When you initialize it, you are setting a moment as of "now" in New York. But then you replace the values one property at a time. This doesn't take into account that "now" might not have the same offset as the date you are feeding it due to daylight saving time fluctuations.
Moment-timezone doesn't currently have functionality to create a moment from a time in a particular zone. This has been requested in issue #11, and there is a pull-request that has been merged in #25, but has not yet been released. If you want to work with the development version from the sources, you can try it out now, such as follows:
var m = moment.tz("2013-10-08T12:00:00","America/New_York");
Post a Comment for "Set Specific Time In Specific Timezone Using Momentjs"