class DateTime
def in_time_zone(zone = ::Time.zone)
Time.zone.
as an argument, and the conversion will be based on that zone instead of
You can also pass in a TimeZone instance or string that identifies a TimeZone
as the local zone instead of the operating system's time zone.
This method is similar to Time#localtime, except that it uses Time.zone
DateTime.new(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00
Time.zone = 'Hawaii' # => 'Hawaii'
Returns the simultaneous time in Time.zone.
def in_time_zone(zone = ::Time.zone) if zone ActiveSupport::TimeWithZone.new(utc? ? self : getutc, ::Time.find_zone!(zone)) else self end end