Skip to content

Instantly share code, notes, and snippets.

@wizardfrag
wizardfrag / gist:5532597
Last active December 17, 2015 01:59
Convert a time string to an integer.
<?php
function string2int($string = "00:00:00") {
$seconds = 0;
$string_parts = explode(':', $string);
$exponent = 0;
while (($timepart = array_pop($string_parts)) !== NULL) {
$timepart = intval($timepart);
$seconds += intval($timepart * pow(60, $exponent));
$exponent++;