Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Time#getlocal

getlocal(zone = nil) → new_time

Returns a new Time object representing the value of self converted to a given timezone; if zone is nil, the local timezone is used:

Example
t = Time.utc(2000)                    # => 2000-01-01 00:00:00 UTC
t.getlocal                            # => 1999-12-31 18:00:00 -0600
t.getlocal('+12:00')                  # => 2000-01-01 12:00:00 +1200

For forms of argument zone, see Timezone Specifiers.

See also #getgm #getutc #friday? #gmt? also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0