This has been an issue before in Trek. Remember when the Enterprise E got from the Romulan Neutral Zone back to Earth very fast in First Contact?
We don't know how long the trip took. Of course, the Romulan Neutral Zone is pretty close to Earth since the war occured early during space exploration. Maybe Starfleet parked the Enterprise close by just in case.