
Originally Posted by
Schwalbach
I would be entering both at the same time, and would have to enter them manually because like otherwise I don't know how to do it...I would be putting in the starting time, then playing a game for however long I played it, then I would get the ending time, so how would I get each seperately?
Off Topic:
You play games for a living? man, I want your job!
Here is a full working page I whipped up for you to play with:
PHP Code:
<?
$start_time = $_REQUEST['start_time'];
$end_time = $_REQUEST['end_time'];
$action = $_REQUEST['action'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<h3>Parse Times</h3>
<form action="<?= $_SERVER['PHP_SELF'] ?>">
Enter the start time (hours:minutes)
<input type="text" name="start_time" value="<?= $start_time ?>" size="60"> <br/>
Enter the end time (hours:minutes)
<input type="text" name="end_time" value="<?= $end_time ?>" size="60"> <br/>
<input type="submit" value="Go!"> <br/>
<input type="hidden" name="action" value="go">
</form>
<hr>
<?
if($action && ($action == "go")){
list($hours, $minutes) = split(':', $start_time);
$startTimestamp = mktime($hours, $minutes);
list($hours, $minutes) = split(':', $end_time);
$endTimestamp = mktime($hours, $minutes);
$seconds = $endTimestamp - $startTimestamp;
$minutes = ($seconds / 60) % 60;
$hours = round($seconds / (60 * 60));
echo "Time passed: <b>$hours</b> hours and <b>$minutes</b> minutes";
}
?>
</body>
</html>
Bookmarks