JavaScript toDateString

The JavaScript toDateString function returns the Date portion of a given date in a human-readable format. The syntax of the JavaScript toDateString Date function is:

 Date.toDateString()

JavaScript toDateString Function Example

We use the toDateString function to return the data portion of today’s date.

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

  var x = dt.toDateString();
  document.write("After toDateString() = " + x);
</script>
</body>
</html>
JavaScript toDateString Function Example

Date and Time: Fri Nov 09 2018 11:56:52 GMT+0530 (Indian Standard Time)
After toDateString() = Fri Nov 09 2018

JavaScript to Date String Function Example 2

This JavaScript toDateString example returns the string date of a custom date in a human-readable format.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript toDateString Function  </title>
</head>
<body>
    <h1> JavaScript toDateString Example </h1>
<script>
  var dt = Date(2017, 5, 15, 10, 11, 19);
  document.write("Date and Time : " + dt + "<br/>");

  var x = dt.toDateString();
  document.write("After toDateString() = " + x);
</script>
</body>
</html>
JavaScript toDateString Function 2