Skip to content

Instantly share code, notes, and snippets.

@kfriend
Created August 27, 2013 22:18
Show Gist options
  • Save kfriend/6359887 to your computer and use it in GitHub Desktop.
Save kfriend/6359887 to your computer and use it in GitHub Desktop.
PHP: Time-to-seconds helper functions
<?php
function time_to_seconds($time = 0)
{
list($secs, $mins, $hours) = array_pad(array_reverse(explode(':', $time)), 3, 0);
return ($hours * 3600) + ($mins * 60) + $secs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment