It will take you about an hour to get to Manhattan and one hour back to JFK so that will leave you about three hours to have some fun. Suggest taking the NYAS bus from your terminal to Port Authority Bus Terminal (42nd St. & 8th Ave.) which is a block from Times Square. Walk around midtown and check out the sights. You can return to Port Authority for the NYAS bus back to JFK or if you're near Grand Central Station (42nd St. & Park Ave.) or Penn Station (33rd St. & 7th Ave.) you can get the NYAS bus there as well.
It will take you about an