Ruby | Time + method Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The + is an inbuilt method in Ruby returns a time after adding given time in seconds Syntax: time + Parameters: The function accepts no parameter Return Value: It returns a time after adding given time in seconds Example 1: CPP # Ruby code for + method # Include Time require 'time' # Declaring time a = Time.new(1993, 02, 24, 12, 0, 0, "+09:00") # Prints time after one year puts a + (60*60*24*365) Output: 1994-02-24 12:00:00 +0900 Example 2: CPP # Ruby code for + method # Include Time require 'time' # Declaring time a = Time.new(1993, 02, 24, 12, 0, 0, "+09:00") # Prints time puts a + (0) Output: 1993-02-24 12:00:00 +0900 Comment More infoAdvertise with us Next Article Ruby | Time <=> method G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Time-class Similar Reads Ruby | Time <=> method The is an inbuilt method in Ruby returns -1, 0, 1 depending on whether time is less than, equal to, or greater than other time. It is returns nil if two times are incomparable. Syntax: time <=> otherTime Parameters: The function accepts no parameter Return Value: It returns -1, 0, 1 depending 1 min read Ruby | Methods Method is a collection of statements that perform some specific task and return the result. Methods are time savers and help the user to reuse the code without retyping the code. Defining & Calling the method: In Ruby, the method defines with the help of def keyword followed by method_name and e 3 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 ctime() function 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: CPP # Ruby code for ctime() method # Include Time require 'tim 1 min read Ruby | Date + method Date#+() is a Date class method which adds a numeric value to the date and returns a date object pointing other days after self. Syntax: Date.+() Parameter: Date values Return: date object pointing other days after self after adding a numeric value to the date. Example #1 : Ruby 1=1 # Ruby code for 2 min read Like