Skip to content
instance method

Time#asctime

() -> ::String
asctime

Alias of #ctime

Returns a string representation of self, formatted by strftime('%a %b %e %T %Y') or its shorthand version strftime('%c'); see Formats for Dates and Times:

Example
t = Time.new(2000, 12, 31, 23, 59, 59, 0.5)
t.ctime                      # => "Sun Dec 31 23:59:59 2000"
t.strftime('%a %b %e %T %Y') # => "Sun Dec 31 23:59:59 2000"
t.strftime('%c')             # => "Sun Dec 31 23:59:59 2000"

Related: Time#to_s, Time#inspect:

Example
t.inspect                    # => "2000-12-31 23:59:59.5 +000001"
t.to_s                       # => "2000-12-31 23:59:59 +0000"
See also #ctime #<=> #as_json #- also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0