Fantasy, as a genre, has largely been associated with the Middle Ages. While this is obviously not always the case, especially with those stories set in the real world (many of which, like Harry Potter, take place in contemporary times), there is some truth to this. The fantasy movement did grow out of the Romantic movement of the 19th century, which was, in part, a reaction against the science and rationalism of the Enlightenment and Industrial Revolution. The “Medievalism” of fantasy is related the genre’s use of magic, awe, emotions, folklore and escapism, as alternatives to the increasingly rationality, homogeneity, and banality of modern existence.
Thus, most constructed fantasy worlds, both historical and mythical, are essentially Medieval European in nature. These can either be based off of the Dark Ages (500-1000) of early Medieval Europe, which gives off an “empty-world” sort of feeling, or the more crowded and better-historically documented High Middle Ages (1000-1350). Jump forward a bit, and you may or may not be in the fantasy genre anymore. This is when you get to Steampunk based off of the 19th century Victorian Era, or the slightly later Dieselpunk, based off of the “interwar period” (1918-1939) through the 1950s. Relatively little fantasy is set in worlds inspired by the ancient and classical periods of human history.