Well, there are several things. It could be influenced by the genre, like if it's a historical fiction, it might be set in a specific past era. Or maybe the author wants to comment on current events and sets it in the present. Also, the story's message or moral might lead to a particular time setting.
The time setting of a story can be determined by the author's imagination or based on real historical periods. Sometimes, it's chosen to fit the theme or mood of the story.
The time of a story can be decided based on the characters and their experiences. If the characters' growth and development are tied to a specific time period, that could determine it. Also, the author's personal interests or research could play a role. Maybe they have a fascination with a certain era and choose to set the story then.