This can be done fairly steadily with the following:
'01:02:03'.split(':').reduce((acc,time) => (60 * acc) + +time);
This is because each unit of time in hours, minutes, and seconds is a multiple of 60 more than the smaller unit. Time is divided into component minutes and seconds, and then reduced to several seconds using the accumulated value of higher units times 60 when it passes through each block.
+time used to indicate the time of a number.
It basically ends with: (60 * ((60 * HHHH) + MM)) + SS
Paul Jul 25 '17 at 1:49 on 2017-07-25 01:49
source share