Dates, Time, and Formatting
Time Objects
Ruby's Time class represents a specific clock time with an explicit offset.
Time Objects
time_objects.rb
require "time"
hour =
time = Time.new(2025, 1, 15, hour, 30, 0, "+00:00")
iso = time.iso8601
clock = time.strftime("%H:%M")
offset = time.utc_offset
puts "time=#{iso}"
puts "clock=#{clock}"
puts "offset=#{offset}"
require "time"
hour =
time = Time.new(2025, 1, 15, hour, 30, 0, "+00:00")
iso = time.iso8601
clock = time.strftime("%H:%M")
offset = time.utc_offset
puts "time=#{iso}"
puts "clock=#{clock}"
puts "offset=#{offset}"
require "time"
hour =
time = Time.new(2025, 1, 15, hour, 30, 0, "+00:00")
iso = time.iso8601
clock = time.strftime("%H:%M")
offset = time.utc_offset
puts "time=#{iso}"
puts "clock=#{clock}"
puts "offset=#{offset}"
time object
A `Time` can include date, hour, minute, second, and offset information.