This is the bit i would like in a function "//print out time and day "
This is becuase i use it a few times through the code and it is to long would just like to call it so that i can do the calculations
i would like to store this once every thing after this line"//print out time and day " and call it when i needed it
<?
print "Stay in " . $town2 . " for " . $stay1 . " mins.";
//add the minutes stayed to the current time variables
for ($h1=1; $h1<=$stay1; $h1++)
{
$currentminute = $currentminute + 1;
if ($currentminute == 60)
{
$currentminute = 0;
if ($currenthour == 18)
{
$currenthour = 9;
$day = $day + 1;
}
$currenthour = $currenthour + 1;
}
}
print "<p>Depart from " . $town2 . " at ";
//print out time and day
if ($currenthour < 10)
{
print "0" . $currenthour . ":";
if ($currentminute < 10)
{
print "0" . $currentminute . ":";
if ($currentsecond < 10)
{
print "0" . $currentsecond;
}
else
{
print $currentsecond;
}
}
else
{
print $currentminute . ":";
if ($currentsecond < 10)
{
print "0" . $currentsecond;
}
else
{
print $currentsecond;
}
}
print " on Day " . $day . ".";
}
else
{
print $currenthour . ":";
if ($currentminute < 10)
{
print "0" . $currentminute . ":";
if ($currentsecond < 10)
{
print "0" . $currentsecond;
}
else
{
print $currentsecond;
}
}
else
{
print $currentminute . ":";
if ($currentsecond < 10)
{
print "0" . $currentsecond;
}
else
{
print $currentsecond;
}
}
print " on Day " . $day . ".";
}
?>