Ruby | Time now() function
Last Updated :
07 Jan, 2020
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:
# 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:
# 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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...