Javascript - Date getDate() Method

The getDate() method returns the day of the month (from 1 to 31) for the date object.

Description

The getDate() method returns the day of the month (from 1 to 31) for the date object.

Syntax

Date.getDate()

Parameters

None

Return

A Number, from 1 to 31, representing the day of the month

Example

Return the day of the month:

Demo

//display todays day of the month.
var d = new Date();
var n = d.getDate();
console.log(n);/*  w ww  . j a  v a  2s  . co m*/

//Return the day of the month from a specific date:

var d = new Date("July 21, 2010 01:15:00");
var n = d.getDate()
console.log(n);

Result