Open In App

Ruby | Time now() function

Last Updated : 07 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
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:




# 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
Previous
Next
Share your thoughts in the comments

Similar Reads