Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Ruby | Time ctime() function

  • Last Updated : 07 Jan, 2020

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:




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

Output:

Wed Feb 24 12:00:00 1993

Example 2:




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

Output:

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