Javascript Function to Print the Number of Days in a Month

To print the number of days in a given month, we can use the getDate() javascript function. This will returns the total days of the month according to local time.

getDate() function return the data in integar format from 1 to 31.

Syntax is:

Javascript Function to Get Days in Month:

You can try below code to get a number of days in a specified month and year :−

In this code, we are passing two parameters in getDate() function. One is month value and second is year.

As you see above javascript code will print the number of days of April and June month. We have passed two parameters to get the total number of days and getDate() returned the days value in integer format.

 

Recommended Posts For You

About Harish

I am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me at - [email protected]

View all posts by Harish