Ruby | DateTime rfc2822() function Last Updated : 09 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report DateTime#rfc2822() : rfc2822() is a DateTime class method which returns a new DateTime object by parsing from a string according to some typical RFC 3339 formats. Syntax: DateTime.rfc2822() Parameter: DateTime values Return: A new DateTime object by parsing from a string according to some typical RFC 3339 formats. Example #1 : Ruby # Ruby code for DateTime.rfc2822() method # loading library require 'date' # declaring DateTime value date_b = DateTime.rfc2822('Sat, 10 Mar 2015 03:08:02 +0400') # rfc2822 method puts "DateTime rfc2822 form : #{date_b}\n\n" Output : DateTime rfc2822 form : 2015-03-10T03:08:02+04:00 Example #2 : Ruby # Ruby code for DateTime.rfc2822() method # loading library require 'date' # declaring DateTime value date_a = DateTime.rfc2822('Mon, 3 Feb 2001 04:05:06 +0700') # rfc2822 method puts "DateTime rfc2822 form : #{date_a}\n\n" Output : DateTime rfc2822 form : 2001-02-03T04:05:06+07:00 Comment More infoAdvertise with us Next Article Ruby | DateTime parse() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby DateTime-class Similar Reads Ruby | DateTime rfc822() function DateTime#rfc822() : rfc822() is a DateTime class method which returns a new DateTime object by parsing from a string according to some typical RFC 2822 formats. Syntax: DateTime.rfc822() Parameter: DateTime values Return: a new DateTime object by parsing from a string according to some typical RFC 2 1 min read Ruby | DateTime rfc3339() function DateTime#rfc3339() : rfc3339() is a DateTime class method which returns the rfc3339 standard value of DateTime object. It is equivalent to strftime('%FT%T%:z'). Syntax: DateTime.rfc3339() Parameter: DateTime values Return: rfc3339 standard value of DateTime object. Example #1 : Ruby # Ruby code for 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 jd() function DateTime#jd() : jd() is a DateTime class method which returns a DateTime object denoting the given chronological Julian day number. Syntax: DateTime.jd() Parameter: DateTime values Return: DateTime object denoting the given chronological Julian day number. Example #1 : Ruby # Ruby code for DateTime. 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 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 Like