Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Time#asctime
asctime
time.c
View on GitHub ↗
static VALUE
time_asctime(VALUE time)
{
return strftimev("%a %b %e %T %Y", time, rb_usascii_encoding());
}
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"