Here’s a demonstration of several Ruby methods for date/time conversion:

$ irb
irb(main):005:0> require 'date'
=> false
irb(main):006:0> dt =,12,25)
irb(main):007:0> dt
=> #<Date: 2020-12-25 ((2459209j,0s,0n),+0s,2299161j)>
irb(main):008:0> dt.to_time
=> 2020-12-25 00:00:00 -0800
irb(main):009:0> dt.to_time.to_i
=> 1608883200
irb(main):010:0> tm =
=> 2020-12-25 00:00:00 -0800
irb(main):011:0> dtm = tm.to_datetime
=> "2020-12-25T00:00:00-08:00"
irb(main):017:0> dtm.strftime("%A, %B %e, %Y")
=> "Friday, December 25, 2020"

This does the following:

  1. Requires the Date standard library
  2. Creates a date
  3. Converts a date to a Time object
  4. Converts a Time instance to an integer value representing the number of seconds since the Unix epoch (January 1, 1970)
  5. Calls the Time class method at to instantiate a new Time object based on this number of seconds
  6. Converts this time to a DateTime
  7. Uses string formatting to return a custom presentation

The last method is particularly useful–see the strftime documentation for a full listing of formatting options.