JavaScript for differentiation of two different dates
following is the Java script for getting difference between two different dates
<script type="text/javascript">
function DateDifference()
{
var startDate = document.getElementById('<%=txtStartDate.ClientID%>').value;
var endDate = document.getElementById('<%=txtEndDate.ClientID%>').value;
var startDateSplit = startDate.split("/");
var endDateSplit = endDate.split("/");
var stDate = new Date(startDateSplit[2], startDateSplit[0]-1, startDateSplit[1]);
var enDate = new Date(endDateSplit[2], endDateSplit[0]-1, endDateSplit[1]);
var difference = (enDate.getTime() - stDate.getTime())/(1000*60*60*24);
document.getElementById('<%=txtTotalDays.ClientID%>').value = difference+1;
}
</script>
following is the Java script for getting difference between two different dates
<script type="text/javascript">
function DateDifference()
{
var startDate = document.getElementById('<%=txtStartDate.ClientID%>').value;
var endDate = document.getElementById('<%=txtEndDate.ClientID%>').value;
var startDateSplit = startDate.split("/");
var endDateSplit = endDate.split("/");
var stDate = new Date(startDateSplit[2], startDateSplit[0]-1, startDateSplit[1]);
var enDate = new Date(endDateSplit[2], endDateSplit[0]-1, endDateSplit[1]);
var difference = (enDate.getTime() - stDate.getTime())/(1000*60*60*24);
document.getElementById('<%=txtTotalDays.ClientID%>').value = difference+1;
}
</script>
No comments:
Post a Comment