My question is Find number of days between the two given dates by using javascript. See below code, copy and paste the code into your html page in head tag.
<script>
function DiffInDays(startDate, endDate){
startDate = new Date(startDate);
endDate = new Date(endDate);
if(endtDate.getTime() > startDate.getTime())
{
var diffDays = endDate.getDate() - startDate.getDate();
alert("Difference in Days :"+diffDays/86400000);// MilliSeconds for one day is 1000*60*60*24
}
else if(endtDate.getTime() == startDate.getTime()){
alert("StartDate and endDate are equal");
}
}
</script>
<script>
function DiffInDays(startDate, endDate){
startDate = new Date(startDate);
endDate = new Date(endDate);
if(endtDate.getTime() > startDate.getTime())
{
var diffDays = endDate.getDate() - startDate.getDate();
alert("Difference in Days :"+diffDays/86400000);// MilliSeconds for one day is 1000*60*60*24
}
else if(endtDate.getTime() == startDate.getTime()){
alert("StartDate and endDate are equal");
}
}
</script>
No comments:
Post a Comment