Open In App

Ruby | Time now() function

Last Updated : 07 Jan, 2020
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report
The now() is an inbuilt method in Ruby returns the current time.
Syntax: time.now() Parameters: The function accepts no parameter Return Value: It returns the current time
Example 1: CPP
# Ruby code for now() method

# Include Time
require 'time'

# Declaring time 
a = Time.now()

# Prints current time 
puts a
Output:
2019-08-27 08:26:42 +0000
Example 2: CPP
# Ruby code for now() method

# Include Time
require 'time'

# Declaring time 
a = Time.now()

# Prints current time 
puts a
Output:
2019-08-27 08:26:42 +0000

Next Article

Similar Reads