Hey, Would you like to work at Home ?? Just click here No need to pay, just register free and activate your account and get data Entry Work at your Home.

Wednesday, November 26, 2008

Date Diffrence In Days

Introduction

This code will give you the diffrence between the two dates in days.Some time it is required in the program to get diff. between two dates.It is so small and very efficient code.

//


// Any source code blocks look like this

//


t1="10/10/2006" ;

t2="15/10/2006";


//Total time for one day

var one_day=1000*60*60*24;

//Here we need to split the inputed dates to convert them into standard format

for furter execution
var x=t1.split("/");
var y=t2.split("/");
//date format(Fullyear,month,date)


var date1=new Date(x[2],(x[1]-1),x[0]);

var date2=new Date(y[2],(y[1]-1),y[0])
var month1=x[1]-1;
var month2=y[1]-1;

//Calculate difference between the two dates, and convert to days



_Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day));
//_Diff gives the diffrence between the two dates.





No comments:

Your Ad Here