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 Comment More infoAdvertise with us Next Article Ruby | Time now() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Time-class Similar Reads Ruby | Time min function Time#min() : min() is a Time class method which returns the minute of the hour from 0 to 59 for time. Syntax: Time.min() Parameter: Time values Return: minute of the hour from 0 to 59 for time. Example #1 : Ruby # Ruby code for Time.min() method # declaring time a = Time.new(2019) # declaring time b 2 min read Ruby | Time mon() function The mon() is an inbuilt method in Ruby returns the month of the year for time. Syntax: time.mon() Parameters: The function accepts no parameter Return Value: It returns the month of the year for time. Example 1: CPP # Ruby code for mon() method # Include Time require 'time' # Declaring time a = Time 1 min read Ruby | Time + function Time#+() is a Time class method which returns a new time value after adding seconds to it. Syntax: Time.+() Parameter: Time values Return: new time value after adding seconds to it Example #1 : Ruby # Ruby code for Time.+() method # declaring time a = Time.new(2019) # declaring time b = Time.new(201 2 min read Ruby | Time - function Time#-() is a Time class method which returns a new time value after subtracting seconds from it. Syntax: Time.-() Parameter: Time values Return: new time value after subtracting seconds from it. Example #1 : Ruby # Ruby code for Time.-() method # declaring time a = Time.new(2019) # declaring time b 2 min read Ruby | Time hour function Time#hour() is a Time class method which returns the hour of the day from 0 to 23 for the time. Syntax: Time.hour() Parameter: Time values Return: the hour of the day from 0 to 23 for the time. Example #1 :Â Ruby # Ruby code for Time.hour() method # declaring time a = Time.new(2019) # declaring time 2 min read Like