How to get before 30 days date from current date using JavaScript
Many time , we need to show before(previous) date or
after (next date) from the current date .In the previous article we have how to get next 30days datefrom current date and now we are going to show pervious date from current date
Source Code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Get
Date .aspx.cs" Inherits="Get_Date_" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function
getdates() {
var
today = new Date()
var
beforedate = new Date();
beforedate.setDate(beforedate.getDate() - 30)
document.getElementById('lblCurrentDate').innerHTML
= today;
document.getElementById('lblBeforeDate').innerHTML
= beforedate;
}
</script>
</head>
<body onload="getdates()">
<div>
<b>Current
Date:</b>
<label id="lblCurrentDate" />
</div>
<br>
<div>
<b>Before
30 days </b>
<label id="lblBeforeDate" />
</div>
</body>
</html>
OUT-PUT:-
How to get before 30 days date from current date using JavaScript
Reviewed by NEERAJ SRIVASTAVA
on
11:10:00 AM
Rating:
No comments: