How To Get Current Week Firstday in JavaScript?

Sep 29, 2021 . Admin



Hello Friends,

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

Here i will give you many example how you can check javascript get current week firstday. Example : 1
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Get Current Week First Day - MyWebtuts.com </title>
		</head>
		<body>
				<script type="text/javascript">
						function FirstDay(date)
						{
								var diff = date.getDate() - date.getDay() + (date.getDay() === 0 ? -6 : 1);
								return new Date(date.setDate(diff));
						}
						fd = new Date(); 
						document.write(FirstDay(fd).toString());
				</script>
		</body>
</html>
Output :
Mon Jul 26 2021 16:44:22 GMT+0530 (India Standard Time)
Example : 2
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Get Current Week First Day - MyWebtuts.com </title>
		</head>
		<body>
				<script type="text/javascript">
						function FirstDay(date)
						{
								var diff = date.getDate() - date.getDay() + (date.getDay() === 0 ? -6 : 1);
								return new Date(date.setDate(diff));
						}
						fw = new Date(); 
						document.write(FirstDay(fw).toString());
				</script>
		</body>
</html>
Output :
Mon Jul 26 2021 16:52:21 GMT+0530 (India Standard Time)

It will help you....

#Javascript