This scene rather speaks for itself: https://www.youtube.com/watch?v=XW5Qx7jU9pU
But if you really want to be convinced, I've gotta recommend this deep dive: https://www.youtube.com/watch?v=DiW3wOUgBTY
Obviously rife with spoilers for both TOS and the films, though.
Actually, there was just a lot of downtime between shots of STV. Kirk, Spock, and McCoy spent about 40 years in that brig cell waiting for Scott to break them out. By the time they made it back home they had caught up to the TNG era. That's why Worf was able to serve as as defense attorney in the trial in STVI. It's obvious when you think about it.