JSFiddle - React, Tailwind, and code Playground

JavaScript

var x = "22:10";
var y = "23:15";

var xTotal = parseInt(x.split(':')[0] * 60) + parseInt(x.split(':')[1]);
var yTotal = parseInt(y.split(':')[0] * 60) + parseInt(y.split(':')[1]);
var total = yTotal - xTotal;

var minutes = Math.floor(total / 60);
var seconds = total - minutes * 60;

if(seconds.toString().length == 1)
{
    seconds = seconds.toString();
    seconds = '0' + seconds;
}

var final = minutes.toString() + ':' + seconds.toString();

alert(final);