For Developers
How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in Ruby — plus the specific mistake that trips up Ruby code more than any other.
Time.now.to_i
Time.at(1750000000).utc
Time.parse("2025-06-15 12:00:00 UTC").to_i
Time.now returns a time in the system's local zone, not UTC, and calling .to_i on it still gives the correct Unix timestamp (Unix time is zone-independent by definition) — but any formatting you do before converting will silently reflect local time. Call .utc explicitly whenever you need to guarantee what timezone a formatted string represents.
Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.
Related
Every language's snippets side by side, for quick comparison.
Convert any timestamp instantly, no code required.
See one date rendered in ISO, US, EU, and more, at once.