How to use getDate in JavaScript

In this article, I will explain use of getDate() Method in JavaScript Date Object.
  • 2321

JavaScript Date Object

  • Date object is used to work with dates and times.

  • Date objects are created with new Date().

JavaScript getDate() method

  • getDate() method returns the day of the month between 1 to 31 for the specified date according to local time.
  • In getDate() method, the retune value is integer value.

Syntax

Date.getDate()

Example

In the following example show to getDate() method returns current date.

<!DOCTYPE html>

<html>

<body>

<h3 style="color:Blue">JavaScript getDate() Method Example</h3>

<p id="demo">Click the button to display todays day of the month.</p>

<button onclick="myFunction()">Click ON</button>

<script type="text/javascript">

    function myFunction() {

        var d = new Date();

        var x = document.getElementById("demo");

        document.write("Today Date is: " + d.getDate());

    }

</script>

</body>

</html>

Output1

getDate 1.jpg

Output2

getDate 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.