["The Sands of Time"](http://www.isfdb.org/cgi-bin/title.cgi?48004), a novella by [P. Schuyler Miller](https://en.wikipedia.org/wiki/P._Schuyler_Miller); first published in [*Astounding Stories*, April 1937](http://www.isfdb.org/cgi-bin/pl.cgi?57375+c), available at the [Internet Archive](https://archive.org/stream/Astounding_v19n02_1937-04#page/n121). (Now I'm going to post some excerpts from the story to show how it matches up with the details in your question.)