JavaScript getDate function will return the day of the month and it will be used as date.getDate(). In the below example, we will display day in innerHTML of span tag using document.getElementById("sample").innerHTML = day;
<!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();
var day = date.getDate();
document.getElementById("sample").innerHTML = day;
}
</script>
</body>
</html>