tags:

views:

172

answers:

2

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
i need only the time conversions, not with date.
Kishh
Dates, times: they're all the same thing. Notice in the answers how they mix dates and times without caution!
wallyk
+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