Ruby | DateTime rfc822() function
Last Updated :
09 Jan, 2020
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 2822 formats.
Example #1 :
require 'date'
date_b = DateTime.rfc822( 'Sat, 10 Mar 2015 03:08:02 +0400' )
puts "DateTime rfc822 form : #{date_b}\n\n"
|
Output :
DateTime rfc822 form : 2015-03-10T03:08:02+04:00
Example #2 :
require 'date'
date_a = DateTime.rfc822( 'Mon, 3 Feb 2001 04:05:06 +0700' )
puts "DateTime rfc822 form : #{date_a}\n\n"
|
Output :
DateTime rfc822 form : 2001-02-03T04:05:06+07:00
Share your thoughts in the comments
Please Login to comment...