while ($next_result = pg_fetch_array($next_on) ) { //Loop through the results reformatting the $dt = substr($next_result["starts"],1,strlen($string)-3) $next_date = date('ga n/j Y', $dt); }