main.rb110 chars3 lines
In this example, we create a new DateTime
object with the DateTime.new
method and pass in the year, month, day, hour, minute, and second. We also pass in a time zone offset of '-5' to account for any time zone differences.
We then use the strftime
method on the date
object to format it into the desired string format. %B
represents the full month name, %d
represents the day of the month, %Y
represents the year, %I
represents the hour in 12-hour format, %M
represents the minute, %S
represents the second, %L
represents the milliseconds, and %p
represents the AM/PM designation.
gistlibby LogSnag