Last active
August 29, 2015 14:08
-
-
Save etozzato/f67e2adb0975b6a06d66 to your computer and use it in GitHub Desktop.
Working with ActiveSupport::TimeZone
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
// MomentJS can use different types of timezone offset | |
// including the one obtained by ActiveSupport::TimeZone | |
var timezone_offset = "+01:00"; | |
console.log(moment().zone(timezone_offset).format('LLLL')); | |
> Tuesday, October 28 2014 7:51 PM | |
console.log(moment().format('LLLL')); | |
> Tuesday, October 28 2014 11:51 AM |
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
# Good to know for the future when | |
# dealing with daylight saving time | |
timezone = 'Rome' | |
$ ActiveSupport::TimeZone[timezone].now.formatted_offset | |
> "+01:00" | |
$ ActiveSupport::TimeZone[timezone].formatted_offset | |
> "+01:00" | |
timezone = 'Pacific Time (US & Canada)' | |
$ ActiveSupport::TimeZone[timezone].now.formatted_offset | |
> "+07:00" | |
$ ActiveSupport::TimeZone[timezone].formatted_offset | |
> "+08:00" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment