Ruby | DateTime now() function Last Updated : 09 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report DateTime#now() : now() is a DateTime class method which returns a DateTime object denoting the given calendar date. Syntax: DateTime.now() Parameter: DateTime values Return: DateTime object denoting the given calendar date. Example #1 : Ruby # Ruby code for DateTime.now() method # loading library require 'date' # declaring DateTime value date_a = DateTime.now() # now method puts "DateTime now form : #{date_a}\n\n" Output : DateTime now form : 2019-08-30T15:14:33+02:00 Example #2 : Ruby # Ruby code for DateTime.now() method # loading library require 'date' # declaring DateTime value date_b = DateTime.now() # now method puts "DateTime now form : #{date_b}\n\n" Output : DateTime now form : 2019-09-02T10:36:47+00:00 Note : The output depends on the time at which the code runs on your system. Comment More infoAdvertise with us Next Article Ruby | DateTime new() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby DateTime-class Similar Reads Ruby | DateTime new() function DateTime#new() : new() is a DateTime class method which returns a DateTime object denoting the given calendar date. Syntax: DateTime.new() Parameter: DateTime values Return: a DateTime object denoting the given calendar date. Example #1 : Ruby # Ruby code for DateTime.new() method # loading library 2 min read Ruby | DateTime hour() function DateTime#hour() : hour() is a DateTime class method which returns the hours i.e. from 0 to 23 from the given DateTime object. Syntax: DateTime.hour() Parameter: DateTime values Return: hours i.e. from 0 to 23 from the given DateTime object Example #1 : Ruby # Ruby code for DateTime.hour() method # l 2 min read Ruby | DateTime minute() function DateTime#minute() : minute() is a DateTime class method which returns the minute value for the given DateTime object. Syntax: DateTime.minute() Parameter: DateTime values Return: the minute value for the given DateTime object. Example #1 : Ruby # Ruby code for DateTime.minute() method # loading libr 2 min read Ruby | DateTime iso8601() function DateTime#iso8601() : iso8601() is a DateTime class method which returns the iso8601 standard for the given DateTime object. Syntax: DateTime.iso8601() Parameter: DateTime values Return: iso8601 standard for the given DateTime object. Example #1 : Ruby # Ruby code for DateTime.iso8601() method # load 2 min read Ruby | DateTime ordinal() function DateTime#ordinal() : ordinal() is a DateTime class method which returns a DateTime object denoting the given ordinal date. Syntax: DateTime.ordinal() Parameter: DateTime values Return: a DateTime object denoting the given ordinal date. Example #1 : Ruby # Ruby code for DateTime.ordinal() method # lo 1 min read Ruby | DateTime parse() function DateTime#parse() : parse() is a DateTime class method which parses the given representation of date and time, and creates a DateTime object. Syntax: DateTime.parse() Parameter: DateTime values Return: given representation of date and time, and creates a DateTime object. Example #1 : Ruby # Ruby code 1 min read Like