Learn and Learn

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

Ruby – Find Month Day Number – mday Method with Examples

mday method is used to return the day of the month which are starting from 1 to maximum 31. mday is a part of date Library in Ruby.

Syntax of mday Method in Ruby

The syntax of mday Method in Ruby Language is:

 

Parameter of mday Method in Ruby

x – Where x is any valid date object from which the number of the day of that month is required. This parameter is required.

 

Error Handling

If the x parameter is not a valid date object mday method returns an error.

 

Return Value of mday Method in Ruby

mday method will return the number of the day in a particular month.

 

How to Get the Number of the Day in a Month in Ruby?


Output:
13

Ruby – Use of mday


Output:
10

Useful way of using mday in Ruby


Output:
20

Loading...
LearnAndLearn.com © 2018 - All rights reserved