Open In App

Ruby | Time asctime() function

Last Updated : 07 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: CPP
# 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: CPP
# 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

Next Article

Similar Reads