0Pricing
Ruby Academy · Lesson

Time Zones

Handling zones.

Why Time Zones Matter

The same instant looks different depending on location. Mishandling zones causes off-by-hours bugs, so you must be explicit about which zone a time uses.

t = Time.new(2026, 5, 30, 12, 0, 0, '+03:00')
puts(t.zone || t.utc_offset)
puts(t.utc_offset)

UTC: The Reference Zone

UTC (Coordinated Universal Time) is the global reference. Store and compute in UTC, then convert for display.

t = Time.utc(2026, 5, 30, 9, 0, 0)
puts(t.utc?)
puts(t.hour)

All lessons in this course

  1. Time and Date Classes
  2. Parsing and Formatting
  3. Time Arithmetic
  4. Time Zones
← Back to Ruby Academy