I am using telerik controls and i want difference between two datetime variables how can i calculate.
var x=9/1/2012 10:20:00 AM;
var y=9/1/2012 09:00:00 AM;
I want difference between two times throw javascript in to another variable as number.
I am using telerik controls and i want difference between two datetime variables how can i calculate.
var x=9/1/2012 10:20:00 AM;
var y=9/1/2012 09:00:00 AM;
I want difference between two times throw javascript in to another variable as number.
Create two Date type variable and then calculate the difference using -
operator, you will get difference in milliseconds.
var first = new Date(2012,8,1,10,20,0,0);
var second = new Date(2012, 9, 1, 09, 00, 0, 0);
var difference = (second - first); // difference in milliseconds
Here is working demo
You should try something on these lines
var a = new Date('9/1/2012 10:20:00 AM');
var b = new Date('9/1/2012 09:00:00 AM');
// a - b this should give you the diff
var diff = a - b;
alert(diff/1000); // this should be value in seconds i.e 4800