In this example, we are going to set the date in date variable as new Date("April 6, 1992 03:14:00") and then getDate of this method, which will return the day as 6.
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<button onclick="getDay()">Show me the day</button>
<p id="sample"></p>
<script>
function getDay() {
var date = new Date("April 6, 1992 03:14:00");
var day = date.getDate();
document.getElementById("sample").innerHTML = day;
}
</script>
</body>
</html>