Skip to content

Instantly share code, notes, and snippets.

@jeystaats
Created February 25, 2017 11:25
Show Gist options
  • Save jeystaats/fcafa327985e41aec78d756447321dd1 to your computer and use it in GitHub Desktop.
Save jeystaats/fcafa327985e41aec78d756447321dd1 to your computer and use it in GitHub Desktop.
<?php
function HHMMSStoSeconds($time) {
return strtotime("1970-01-01 $time UTC");
}
function secondsToHHMMSS($seconds) {
return sprintf("%02d%s%02d%s%02d", floor($seconds / 3600), ':', ($seconds / 60) % 60, ':', $seconds % 60);
}
// Time to decimal converter
function timeToDecimal($time) {
$timeArr = explode(':', $time);
$decTime = ($timeArr[0] * 60) + ($timeArr[1]) + ($timeArr[2] / 60);
return $decTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment