Time To Minutes



function timeToMinutes(time) {
        time = time.split(/:/);
        return (time[0] * 60) + time[1] * 1;

    }




You can parse the time with this:
function timeToSeconds(time) {
    time = time.split(/:/);
    return time[0] * 3600 + time[1] * 60 + time[2];
}
It returns a number of seconds since 00:00:00, so you can compare the results easily:
timeToSeconds('06:53:22') < timeToSeconds('19:23:58')

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...