"The Sands of Time", a novella by P. Schuyler Miller; first published in Astounding Stories, April 1937, available at the Internet Archive.
(Now I'm going to post some excerpts from the story to show how it matches up with the details in your question.)