Doing time subtraction with jQuery -


i have 2 time values on page:

8:00 22:30 

i need subtract 8 22:30 , 14:30.

is there straight forward way in jquery? plug-ins fine me if they're necessary.

update: second number grand total like

48:45 

anything subtract should subtract value total, not date related calculations.

you can in javascript.

suppose have start = '8:00' , end = '22:30'. code follows:

<script type="text/javascript">     var start = '8:00';     var end = '23:30';      s = start.split(':');     e = end.split(':');      min = e[1]-s[1];     hour_carry = 0;     if(min < 0){         min += 60;         hour_carry += 1;     }     hour = e[0]-s[0]-hour_carry;     diff = hour + ":" + min;      alert(diff); </script> 

in end, diff time difference.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -