How To Get Current Month First Day in JavaScript?

Jul 30, 2021 . Admin

Hello Friends, Now let's see example of how to use javascript get current month first day example. We will use how to use if get current month first day in javascript. Here you will learn how to use javascript get current month first day. This is a short guide on get current month first day. Let's get started with how to get current month first day in javascript. Here i will give you many example how you can check javascript get current month first day. Example: 1
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>How to get current month first day in javascript?</title>
	</head>
	<body>
		<script type="text/javascript">
			function startOfMonth(date)
	  		{
	  			return new Date(date.getFullYear(), date.getMonth(), 1);
	  		}
	  		dt = new Date();
	  		console.log(startOfMonth(dt).toString());
		</script>
	</body>
</html>
Output:
Thu Jul 01 2021 00:00:00 GMT+0530 (India Standard Time)
Example: 2
<html>
    <head>
        <title>How to get current month first day in javascript?</title>
    </head>
    <body>
        <script>
            var date = new Date();
            var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
            document.write("<br>"+firstDay);
        </script>
    </body>
</html>
Output:
Thu Jul 01 2021 00:00:00 GMT+0530 (India Standard Time)

It will help you....

#Javascript