JavaScript getDate Function

JavaScript getDate function is one of the Date Function, which is used to return the Day number from a given date. In this article, we show how to use Get Date in JavaScript Programming with an example.

JavaScript getDate Function Example

The following example helps you understand the JavaScript get Date Function. Here, we are using JavaScript getdate to return date from the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Date Functions </title>
</head>
<body>
    <h1> JavaScript getDate Function Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("Date from getDate(): " + dt.getDate());
</script>
</body>
</html>
JavaScript getDate Function Example

Date and Time: Sat Nov 03 2018 15:34:10 GMT+0530 (Indian Standard Time)
Date from getDate(): 3

JavaScript get Date Function Example 2

In this JavaScript getDate Function example, we are extracting date number from the custom date

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Date Functions </title>
</head>
<body>
    <h1> JavaScript getDate Function Example </h1>
<script>
  var dt = Date("January 22, 2014 10:09:07");
  document.write("Date and Time : " + dt);
  document.write("Date from getDate(): " + dt.getDate());
</script>
</body>
</html>
JavaScript getDate Function 2