Let's say your query went like this;
$results = mysql_query("SELECT timestamp, etc FROM test ORDER BY timestamp DESC");
You could then put the results into an array:
while ($row = mysql_fetch_assoc($results)) {
$ts_array[] = $row('timestamp');
}
Get the most recent (topmost) timestamp and remove it from the array:
$most_recent = array_shift($ts_array);
Then pass the array to the function to find the first element that's more than one day old:
$first_day_old = day_old_ts($ts_array);
if ($first_day_old) {
echo $first_day_old;
} else {
// Function returned false
}