Date getDate() Method - Javascript Date

Javascript examples for Date:getDate

Description

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

Parameters

None

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>
<html>
<body>

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

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

<script>
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;
}
</script>

</body>
</html>

Related Tutorials