Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Time asctime() function

  • Last Updated : 07 Jan, 2020

The asctime() is an inbuilt method in Ruby returns a canonical string representation of time.

Syntax: time.asctime()

Parameters: The function accepts no parameter

Return Value: It returns a canonical string representation of time.



Example 1:




# Ruby code for asctime() method
  
# Include Time
require 'time'
  
# Declaring time 
a = Time.new(1993, 02, 24, 12, 0, 0, "+09:00")
  
# Prints time as string 
puts a.asctime()

Output:

Wed Feb 24 12:00:00 1993

Example 2:




# Ruby code for asctime() method
  
# Include Time
require 'time'
  
# Declaring time 
a = Time.now.asctime()
  
# Prints time as string 
puts a

Output:

Tue Aug 27 08:22:03 2019
My Personal Notes arrow_drop_up
Recommended Articles
Page :