instance method
formatted_offset
Ruby on Rails 4.0.13
Since v2.2.3Signature
formatted_offset(colon = true, alternate_utc_string = nil)
Returns a formatted string of the offset from UTC, or an alternative string if the time zone is already UTC.
Time.zone = 'Eastern Time (US & Canada)' # => "Eastern Time (US & Canada)" Time.zone.now.formatted_offset(true) # => "-05:00" Time.zone.now.formatted_offset(false) # => "-0500" Time.zone = 'UTC' # => "UTC" Time.zone.now.formatted_offset(true, "0") # => "0"
Parameters
-
colonopt = true -
alternate_utc_stringopt = nil
Source
# File activesupport/lib/active_support/time_with_zone.rb, line 120
def formatted_offset(colon = true, alternate_utc_string = nil)
utc? && alternate_utc_string || TimeZone.seconds_to_utc_offset(utc_offset, colon)
end
Defined in activesupport/lib/active_support/time_with_zone.rb line 120
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::TimeWithZone