Time
classnow
method which will return a Time
object representingcurrent_time = Time.now puts current_time
strftime
method and specify the formatting string.puts current_time.strftime("%Y-%m-%d %H:%M:%S %Z")
%Y
, %m
, %d
, %H
, %M
, and %S
are placeholders for year, month, day, hour,%Z
placeholder is for the timezone abbreviation.main.rb0 chars1 lines
gistlibby LogSnag