Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Ruby – Set httpdate Format – httpdate() Method – Examples & Explanation

In Ruby, the httpdate method generates a new date object by describing from a string given in a code. Use Date.httpdate() to get the desired results.

httpdate() Method in Ruby

httpdate() method exists in Standard Date Library of Ruby. The purpose of this method is to get a new date object from a given string.

 

Syntax of the httpdate() Method in Ruby

In date, the syntax of httpdate() method is:

 

Parameter of httpdate() Method in Ruby

x is any valid date object in the form of string. This parameter is required.Note: If the x parameter is not a valid date object in form of a string or if it is zero, httpdate() method will return an error.

 

Return Value of httpdate()

httpdate() method generates a new date object by describing from a string given in a code.

 

Ruby – Get Date with httpdate() Method Example 1


Output
2015-03-02

 

Ruby – Get Date with httpdate() Method Example 2


Output
2015-03-06

 

LearnAndLearn.com © 2018 - All rights reserved