โดย Jubtot Kkn » 21/04/2017 4:48 pm
<?php
$str_time = "01:30:00"; // hours minutes seconds
$str_distance = 5; // 5 km.
$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
$minperkm = ($time_seconds/$str_distance)/60;
echo "min/km = ".$minperkm." minutes/km ";
?>
<?php
$str_time = "01:30:00"; // hours minutes seconds
$str_distance = 5; // 5 km.
$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
$minperkm = ($time_seconds/$str_distance)/60;
echo "min/km = ".$minperkm." minutes/km ";
?>