Date getDate() Method - Javascript Date

Javascript examples for Date:getDate


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



Return Value:

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

The following code shows how to return the day of the month:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/* www.  j ava  2s.  co  m*/
    var d = new Date("July 21, 2020 01:15:00");
    var n = d.getDate()
    document.getElementById("demo").innerHTML = n;


Related Tutorials