leave 1 hour for security, etc. That leaves you with 1-3 hours.
anything over 2 hours: take the airtrain to one of the two subway lines and take them as far as you can. Remember, if you have two hours, go for 1 hour one way, then get off and take a train back. Remember, traveling in one direction may be faster than in the other.