I'm new to javaScript and while working on a simple project i came across this problem. I have a string,
var str = "11 hrs and 34 mins";
and I want to only time in a time format like 11:34
so what i'm doing now is something like this
var str = "11 hrs and 34 mins";
var time="";
var parts=str.split(" ");
for(var i=0;i<parts.length;i++){
if(parseInt((parts[i].trim()), 10)){
time+=parts[i]+" ";
}
}
console.log(time);
Is there a better way of doing this with external libraries or pure javaScript. Can someome help me with that.