JavaScript getDate Function

JavaScript getDate function is one of the Date Function, which is used to return the Day number from a given. 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 getdate to return date from the current datetime.

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

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

JavaScript get Date Function Example 2

In this JavaScript example, we are extracting date number from the custom datetime.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Date Functions </title>
</head>
<body>
    <h1> JavaScript get Date 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