Convert time (hr:min:secs) into seconds

I wrote this snippet to convert ffmpeg’s information output time into seconds, i can then determine the 25, 50 and 75 percentages to create 3 different thumbnails of a movie (using ffmpeg also).

Heres the snippet:

function time2seconds($time='00:00:00'){
  list($hr,$m,$s) = explode(':', $time);
  return ( (int)$hr*3600 ) + ( (int)$m*60 ) + (int)$s;
}

Hope you find this as useful as I have.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)