here is a shorter version that assumes the GET parameter ?time=[integer] (for example ?time=8)
add_filter('posts_where', 'filter_where', 11);
function filter_where($where="") {
if(isset($_GET['time'])){
$time = $_GET['time'];
$time=(int)$time; // only allow integers
if(in_array($time,array(8,24,72))){
$where .= " AND post_date > '".date('Y-m-d H:i:s', strtotime('-".$time." hours'))."'";
}
}
return $where;
}