Ruby | DateTime httpdate() function
DateTime#httpdate() : httpdate() is a DateTime class method which returns a new DateTime object by parsing from a string according to some RFC 2616 format.
Syntax: DateTime.httpdate()
Parameter: DateTime values
Return: A new DateTime object by parsing from a string according to some RFC 2616 format.
Example #1 :
require 'date'
date_a = DateTime.httpdate( 'Sat, 03 Feb 2001 04:05:06 GMT' )
puts "DateTime httpdate form : #{date_a}\n\n"
|
Output :
DateTime httpdate form : 2001-02-03T04:05:06+00:00
Example #2 :
require 'date'
date_a = DateTime.httpdate( 'Tue, 01 Mar 2003 04:15:06 GMT' )
puts "DateTime httpdate form : #{date_a}\n\n"
|
Output :
DateTime httpdate form : 2003-03-01T04:15:06+00:00
Last Updated :
09 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...