How To Check If Date is Older Than 30 Day in JavaScript?


Share:
Published By: Admin, Published On: Sep 20, 2021, Category: Javascript


Hello Friends,

Now let's see example of how to check if date is older than 30 day example. We will use how to check if date is older than 30 day in javascript. Here you will learn how to use javascript check if date is older than 30 day. This is a short guide on check if date is older than 30 day. Let's get started with how to check if date is older than 30 day in javascript.

Here i will give you many example how you can check if date is older than 30 day javascript.

Example : 1
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Check Date is Older Than 30 Days - MyWebtuts.com </title>
		</head>
		<body>
		<script type="text/javascript">
				let now = new Date()
				document.write('Today: ' + now.toUTCString())
				let last30days = new Date(now.setDate(now.getDate() - 30))
				document.write('<br> Last 30th day Ago: ' + last30days.toUTCString())
		</script>
		</body>
</html>
Output :
Today: Mon, 26 Jul 2021 12:50:58 GMT
Last 30th day Ago: Sat, 26 Jun 2021 12:50:58 GMT
Example : 2
<!DOCTYPE html>
<html>
		<head>
				<meta charset="utf-8">
				<title>JavaScript Check Date is Older Than 30 Days - MyWebtuts.com </title>
		</head>
		<body>
		<script type="text/javascript">
				let now = new Date()
				document.write('Current Date: ' + now.toUTCString())
				let last30days = new Date(now.setDate(now.getDate() - 30))
				document.write('<br>30th Day Ago Date: ' + last30days.toUTCString())
		</script>
		</body>
</html>
Output :
Current Date: Mon, 26 Jul 2021 12:51:05 GMT
30th Day Ago Date: Sat, 26 Jun 2021 12:51:05 GMT

It will help you...

Share: