Elsinore, Denmark: in and around the royal palace
The story of Hamlet is set in the late middle ages (14th and 15th centuries, or 1300 to 1499) in and around (mostly) the royal palace in Elsinore, a city in Denmark.
The story may have a specific location and time, but it's not exactly historical drama: the play has a distinct turn-of-the-17th century vibe. (Remember, Hamlet was written between 1599 and 1601).
For starters, there are several allusions to the Protestant Reformation, which wasn't initiated until around 1517, when Martin Luther laid out his beef with the Catholic Church in his Ninety-five Theses. Denmark (like England) was a Protestant nation at the time Shakespeare wrote the play and Hamlet seems to be the quintessential Protestant kid —he goes to school in Wittenberg, Germany (where Martin Luther hung out) and he's also skeptical of the Ghost, who claims to be his father's Purgatorial spirit. (Protestants rejected the notion of Purgatory as mere "superstition" —you can read more about this in our discussion of "Religion.")
There's also a whole lot of play-acting in Hamlet, including a performance of The Murder of Gonzago, which is put on by a troop of traveling players (actors) who drop by the castle to put on a little show. That's just the kind of thing that would have gone down in Elizabethan England. (Be sure to check out "Art and Culture" for more on this.)
We should also point out that contemporary directors of stage and film versions of Hamlet have set the play in places and periods ranging from Elizabethan England to nineteenth century Europe to twenty-first century New York City, where Gertrude and Claudius run a high-powered New York corporation and the ghost of Old Hamlet appears on security televisions in the company's offices. The fact that this setting somehow works is a testament to the universality and relevance of the play's themes.
The Royal Court
Then, of course, there's the fact that the whole thing takes place at Denmark's royal court. The dynamic is high-powered and manipulative, like—well, a lot like a high-powered corporation. Public image matters. Hamlet doesn't just get to be a moody teenager in his own bedroom: he has to do his growing up on stage. (And we all know how well that works out.)
Actually, political kids might be a better analogy: Hamlet's strange behavior is a liability to his parents, who have a political interest in bringing him under control. "Madness in great ones must not unwatched go," says Claudius (3.1.203). It's a big political nightmare for Claudius and Gertrude.
Of course, the royal court isn't the only place Hamlet hangs out. If you want to think about the setting of, say, the graveyard, check out "Symbols, Imagery, Allegory."