Trick-or-Treat Times: When Does Halloween Night Start (and End) for Kids?

Your kids will be scary cranky on Wednesday if they stay up too late trick-or-treating on Halloween. Jemal Countess/Getty

Costumed children, teenagers and adults alike will hit the streets Tuesday night in pursuit of candy, cute photos and some good old-fashioned Halloween fun. And while you may already be in the holiday spirit, you could miss the festivities if you're not keeping an eye on the clock.

Trick-or-treating hours vary by location, in part because they're usually scheduled around sunset. For example: In San Francisco, which Zillow recently named the best city for trick-or-treating, the sun will set at 6:12 p.m. local time. But in Philadelphia, ranked the third-best place to score sweets on Halloween night, it'll get dark at 5:59 p.m. In Milwaukee, the ninth-best place to go door-to-door for treats, sunset is even earlier—5:45 p.m.

If you don't want to take the scientific approach to figuring out when to trick-or-treat, try the mathematical one. In 2015, FiveThirtyEight polled about 900 people and found that the most popular start and end times for trick-or-treating were 6 p.m. and 9 p.m., respectively. But beware: Five percent of respondents said they thought it was OK to ring the doorbell as late as 11 p.m. local time.

Related: Halloween humor: 21 jokes for kids, adults and trick-or-treaters of all ages

Kids, by all means trick or treat at my house later but I swear, if you even CONSIDER knocking during the #GBBOfinal, I will destroy you.

— Nicola Hume (@Nicola_Hume) October 31, 2017

An estimated 41 million kids go trick-or-treating each year, partaking in a tradition that dates back centuries. In the Middle Ages, people would dress up as saints and ask their neighbors for food on behalf of the dead, according to Smithsonian Magazine.

Nowadays, trick-or-treating is a lot more more lighthearted—but it's also becoming more regulated.

The city of Bathurst in New Brunswick, Canada, has a bylaw on the books that allows police to fine trick-or-treaters up to $200 if they are out past 8 p.m. In Detroit, police have said they'll ticket people over age 16 if they violate a curfew in place between 9 p.m. Tuesday and 6 a.m. Wednesday. In Nevada's Clark County, commissioners are pushing a campaign called "inside by 9" to minimize safety risks for youth.

"Children in costume are excited and sometimes don't pay attention to traffic and may dart out into roads with costumes obscuring their vision. Drivers sometimes don't see children until it's too late," Commissioner Lawrence Weekly told the Las Vegas Review-Journal.

No matter where you live or when you trick-or-treat, exercise caution: The Centers for Disease Control and Prevention's Halloween tips webpage tells kids to trick-or-treat in groups, wear reflective tape, look both ways before crossing roads, stay on sidewalks and only approach well-lit houses.