I've written up a little code to calculate pace per mile for long distance races. I am going to have an online calulator, but had to set up a converter first. I had to figure out a way to add in the appropriate "0" for situations where the seconds were less than 10, hence the if at the end.
<?php
//*Define variables
$distance="distance";
$d=26.21865;
$h=10;
$m=31;
$s=14.22;
$t=$h*3600+$m*60+$s;
$pace=$t/$d;
//*Set up concatenation
$pm = intval ($pace/60);
$sc = $pace/60; //*sc=Second Converter
$sc1 = (($sc-$pm)*60); //*sc1=Second Converter 1
$ps = number_format($sc1, 2, ".", ","); //*ps=Pace (in seconds)
?>
<?php
if ($ps<10)
{
print("Your time for the "." ".$distance." "."is: ".$h.":".$m.":".$s.".<br>");
print("Your pace is: ".$pm.":0".$ps.".");
}
elseif ($ps>=10)
{
print("Your time for the "." ".$distance." "."is: ".$h.":".$m.":".$s.".<br>");
print("Your pace is: ".$pm.":".$ps.".");
}
?>
Now I have to set up a page to refer time data input from a user-selected distance and use a variety of scalars to determine various paces. Fun stuff.