In modern times, clocks underpin everything people do, from work to school to sleep. Timekeeping is also the invisible structure that makes modern infrastructure work. It forms the foundation of the high-speed computers that conduct financial trading and even the GPS system that pinpoints locations on Earth’s surface with unprecedented accuracy.

But humans have likely lived by some version of the clock for a very long time. The ancient Egyptians invented the first water clocks and sundials more than 3,500 years ago. Before that, people likely tracked time with devices that did not survive in the archaeological record—such as an upright stick in the dirt that acted as a primitive sundial—or no device at all, says Rita Gautschy, an archeoastronomer at the University of Basel in Switzerland.

“It’s really difficult to get a grip on when people started with timekeeping,” Gautschy says. Simply by observing the location of the sunrise and the sunset each day and by watching how high the sun reaches in the sky, a person can construct a primitive calendar. These early human efforts at understanding the flow of time left no trace at all, she says.

The oldest sundial on record came from Egypt and was made around 1500 B.C.E. It consisted of a simple upright stick and a roughly semicircular base divided into 12 pie-shaped sections. The shadow of the stick gave an approximate hour of the day. Other early sundials measured time by the length of a stick’s shadow as the sun moved across the sky rather than by the movement of the shadow across the base, Gautschy says.

“It’s a first step, and if you accomplish this step, you can do fine-tuning and also adapt to different months,” she says. Sundials must account for both time of year and latitude to be truly accurate.

During the night, ancient people could track time by the apparent movement of the stars from east to west, Gautschy says. And for measuring discrete units of time, they used water clocks. These were vessels that either had holes for water to flow out of at a constant rate or were filled from another vessel and had markings on the inside to indicate increments of time. The oldest surviving water clocks were found in Egypt and Babylon, and the earliest of these date to around 1500 B.C.E. In China historical records claim that water clocks were invented by the Yellow Emperor, or Huangdi, a half-historical, half-mythical figure said to have lived between 2717 and 2599 B.C.E., says Zheng-Hui Hwang, a mechanical engineer at National Cheng Kung University in Taiwan, who has written about the history of ancient Chinese timekeeping devices. The earliest Chinese water clocks were probably outflow devices and were known as louke. The unit ke divided the day into 100 equal segments from midnight to midnight. Over time, Hwang says, inventors made these clocks more sophisticated by equipping them with multiple water supply vessels or otherwise adjusting them to ensure the rate of water flow remained stable.

Water would eventually lead to some extremely sophisticated timekeeping: by the early 700s C.E., Tang Dynasty monks developed a mechanical clock powered by a water wheel, Hwang says. In 1194 Sung Dynasty official Su Song built on this design to develop a 40-foot-tall (12-meter-tall) mechanical clock powered by a water wheel that worked much like the mechanical clocks that would be invented in Europe some 200 years later.

The ancient Chinese timekeeping system also divided each 24-hour day into two-hour segments. This system was also seen in ancient Japan and Korea, according to a 2004 paper in Publications of the Astronomical Society of Japan.

In modern times, an hour is always the same length, but ancient peoples around the world operated with a more complex system, says David Rooney, a historian of technology, former curator of timekeeping at the Royal Observatory in Greenwich, London, and author of About Time: A History of Civilization in Twelve Clocks (W. W. Norton, 2021). Some ancient timekeeping systems divided the light portion of the day into 12 segments and the night into 12 segments, but because days and nights vary in length throughout the year except at the equator, these “seasonal hours” were different lengths from day to night and across the year.

“If your religion demands prayer time being linked to things like sunrise or sunset, or if you’re working in the fields, as most people did then, patterns of daylight and darkness matter more than this idea of a universal hour,” Rooney says.

Seasonal hours coexisted with universal hours until the 15th century in Europe and up until the 19th century in Japan, Rooney says. “We used to live with a much more complex—and rich and diverse—temporal culture,” he adds.

Religion was a major driver of the standardization of time across cultures, both across the year and day to day, Gautschy says. In ancient Mesopotamia, Anatolia (today approximately Iraq and Turkey) and Greece, people developed lunar calendars to track rituals and feast days, she says, whereas people in Egypt focused more on the solar calendar and also had a calendar based on the star Sirius. People of Islamic cultures, Rooney says, used water clocks to track prayer and fasting, whereas Christians developed the mechanical clock in 14th-century Europe as a way to schedule prayer.

The bottom line, Rooney says, is that humans have been temporal creatures for far longer than the industrial age—although not always happily. After the Romans installed their first public sundial in 263 B.C.E., he says, the Roman playwright Plautus objected to the new fad of timekeeping via a character in one of his plays: “The gods damn that man who first discovered the hours, and—yes—who first set up a sundial here, who’s smashed the day into bits for poor me! You know, when I was a boy, my stomach was the only sundial, by far the best and truest compared to all of these.... But now what there is, isn’t eaten unless the sun says so. In fact, town’s so stuffed with sundials that most people crawl along, shriveled up with hunger.”

It’s a strikingly modern thought for being 2,200 years old, Rooney says. “That could be written in the 21st century and spoken in any office,” he says, “that we’re under the tyranny of the clock.”