Ruby | Time asctime() function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share 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 Comment More infoAdvertise with us Next Article Ruby | Time asctime() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Time-class Similar Reads Ruby | Time ctime() function The ctime() is an inbuilt method in Ruby returns a canonical string representation of time. Syntax: time.ctime() Parameters: The function accepts no parameter Return Value: It returns a canonical string representation of time. Example 1: CPP # Ruby code for ctime() method # Include Time require 'tim 1 min read Ruby | Time to_datetime() function Time#to_datetime() is a Time class method which returns a date time object of itself. Syntax: Time.to_datetime() Parameter: Time values Return: a date time object of itself. Example #1 : Ruby # Ruby code for Time.to_datetime() method # loading library require 'time' # declaring time a = Time.new(201 2 min read Ruby | DateTime to_time() function DateTime#to_time() : to_time() is a DateTime class method which returns the time object which denotes the DateTime object self. Syntax: DateTime.to_time() Parameter: DateTime values Return: duplicate DateTime object self and resets its to_time. Example #1 : Ruby # Ruby code for DateTime.to_time() me 2 min read Ruby | Time to_date() function Time#to_date() is a Time class method which returns a self Date object. Syntax: Time.to_date() Parameter: Time values Return: a self Date object. Example #1 : Ruby # Ruby code for Time.to_date() method # loading library require 'time' # declaring time a = Time.new(2019) # declaring time b = Time.new 2 min read Ruby | DateTime strptime() function DateTime#strptime() : strptime() is a DateTime class method which parses the given representation of date and time with the given template Syntax: DateTime.strptime() Parameter: DateTime values Return: parses the given representation of date and time with the given template Example #1 : Ruby # Ruby 1 min read Like