timestamper.online
Back to Guides

How to Handle Unix Timestamps in Ruby

Get and format Unix timestamps in Ruby.

1. Get Current Timestamp
ruby
# Current timestamp
puts Time.now.to_i
2. Convert Date to Timestamp
ruby
# String to timestamp
require 'date'
puts DateTime.parse('2024-01-01T00:00:00+00:00').to_time.to_i
3. Convert Timestamp to Readable Date
ruby
# Timestamp to string
puts Time.at(1704067200).utc

Need to convert a specific timestamp right now?

Use Online Converter