Last active
December 21, 2015 17:08
-
-
Save jayuen/6338077 to your computer and use it in GitHub Desktop.
Converting a local equivalent date into a DateWithTimezone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generate a string that only has the time portion | |
var strWithoutTimezone = moment(localEquivalent).format("YYYY-MM-DDTHH:mm:ss") | |
// extract out the site's timezone identifier (DateWithTimezone.getTimezone() stores the site's timezone) | |
var timezone = moment.tz(DateWithTimezone.getTimezone()).format("Z") | |
// create a moment in the site's timezone and use it to initialize a `DateWithTimezone` | |
return new DateWithTimezone(moment(strWithoutTimezone + timezone)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there, any chance you'd be able to upload the DateWithTimezone object as well?