how to check time difference from two textboxs in javascript.
+3
A:
That is answered in http://stackoverflow.com/questions/41948/how-do-i-get-the-difference-between-two-dates-in-javascript
wallyk
2009-11-24 05:14:40
i need only the time conversions, not with date.
Kishh
2009-11-24 05:20:47
Dates, times: they're all the same thing. Notice in the answers how they mix dates and times without caution!
wallyk
2009-11-24 05:24:05
+1
A:
// this assumes that the times inside the text boxes are parse-able by JavaScript
// these should be OK:
// 11:59 PM
// 23:59
var diff =
new Date( '01/01/2009 ' + document.form1.Date2.value ) -
new Date( '01/01/2009 ' + document.form1.Date1.value );
// diff contains the time difference in milliseconds
// so for seconds...
alert( diff / 1000 );
// for minutes...
alert( diff / 1000 / 60 );
// for hours...
alert( diff / 1000 / 60 / 60 );
Salman A
2009-11-24 05:52:01