instance method
formatted_offset
Ruby on Rails 8.1.2
Since v3.0.20Signature
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.
datetime = DateTime.civil(2000, 1, 1, 0, 0, 0, Rational(-6, 24)) datetime.formatted_offset # => "-06:00" datetime.formatted_offset(false) # => "-0600"
Parameters
-
colonopt = true -
alternate_utc_stringopt = nil
Source
# File activesupport/lib/active_support/core_ext/date_time/conversions.rb, line 53
def formatted_offset(colon = true, alternate_utc_string = nil)
utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon)
end
Defined in activesupport/lib/active_support/core_ext/date_time/conversions.rb line 53
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in DateTime