Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Time#to_a

time.to_a → array

Returns a ten-element array of values for time:

Example
[sec, min, hour, day, month, year, wday, yday, isdst, zone]

See the individual methods for an explanation of the valid ranges of each value. The ten elements can be passed directly to Time.utc or Time.local to create a new Time object.

Example
t = Time.now     #=> 2007-11-19 08:36:01 -0600
now = t.to_a     #=> [1, 36, 8, 19, 11, 2007, 1, 323, false, "CST"]
See also #thursday? #to_date #sunday? #to_datetime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1