JSFiddle - React, Tailwind, and code Playground

by Tushar Gupta

HTML

<table>
    <tr>
        <td>Hour 1</td>
        <td>Hour 2</td>
        <td>Difference</td>
    </tr>
    <tr>
        <td>16:30</td>
        <td>12:10</td>
    </tr>
    <tr>
        <td>12:35</td>
        <td>10:12</td>
    </tr>
</table>

JavaScript

$('table tr:gt(0)').each(function () {
    var str_1 = $(this).find('td:nth(0)').text().split(':');
    var str_2 = $(this).find('td:nth(1)').text().split(':')
    var str_3 = (parseInt(str_1[0]) - parseInt(str_2[0])) + ':' + (parseInt(str_1[1]) - parseInt(str_2[1]));
    $(this).append('<td>'+str_3+'</td>');
});