How To Get Current Week First and Last Day in JavaScript?

Sep 30, 2021 . Admin



Hello Friends,

Now let's see example of how to use javascript get current week firstday and lastday example. We will use how to use if get current week firstday and lastday in javascript. Here you will learn how to use javascript get current week firstday and lastday. This is a short guide on get current week firstday and lastday. Let's get started with how to get current week firstday and lastday in javascript.

Here i will give you many example how you can check javascript get current week firstday and lastday. Example : 1
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Get Current Week First and Last Day - MyWebtuts.com </title>
		</head>
		<body>
				<script type="text/javascript">
						var currentDate = new Date();
						var FirstD = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay())).toUTCString();
						var LastD = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7)).toUTCString();
						document.write(FirstD, LastD)
				</script>
		</body>
</html>
Output :
Sun, 25 Jul 2021 12:43:02 GMTSun, 01 Aug 2021 12:43:02 GMT
Example : 2
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Get Current Week First and Last Day - MyWebtuts.com </title>
		</head>
		<body>
				<script type="text/javascript">
						var currentDate = new Date();
						var firstweekday = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay())).toUTCString();
						var lastweekday = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7)).toUTCString();
						document.write(firstweekday, lastweekday)
				</script>
		</body>
</html>
Output :
Sun, 25 Jul 2021 12:48:28 GMTSun, 01 Aug 2021 12:48:28 GMT

It will help you....

#Javascript