You're likely thinking of Sky Captain and the World of Tomorrow (2004). While not a naval ship, it features a futuristic airship — the "Sky Captain" — transported back to 1939 New York City during WWII's early stages.
If you specifically mean a naval vessel time-traveling to WWII, consider The Final Countdown (1980) — USS Nimitz (modern carrier) goes to 1941 Pearl Harbor. But Sky Captain fits the "modern vehicle in 1939 NYC" memory better.