In the waterfront city of Santa Monica, California, on the western border of Los Angeles, residents have certain expectations about the climate. The days are warm, the nights are cool, and the ocean breeze keeps the temperature comfortable.

Those weather expectations are what Santa Monica native Colin Specter looked forward to when he moved back home from New York in 2016. Instead, Specter and his wife found the region gripped by a series of heatwaves that baked the city even at night.

“It was just hotter than it ever had been the last couple summers,” Specter, 32, said. “Growing up in Los Angeles, that was not the norm.”

Like most older apartments in the city, Specter’s didn’t have air conditioning. They tried to beat the heat with cool sheets and a fan, but that didn’t work. Eventually, tired of sweating in bed, they broke down and bought an air conditioner.

Heatwaves have become more common in California over the past three decades, potentially worsening the state’s wildfire season and, in the case of a prolonged 2006 heat wave, causing scores of deaths. And it’s not just happening in California.

An NBC News analysis of daily temperatures from more than 500 weather stations across the United States shows that over the past 40 years, nights in most regions of the country have warmed more than the days. But far from being a mild annoyance that causes sleepless nights, scientists say the trend is a consequence of a changing climate and warn that it could have dire effects on health and agriculture.

NBC News’ analysis looked at the rate at which record-high and record-low nighttime temperatures were set in each decade. During the 1960s, weather stations across the country recorded approximately 0.9 record-high night temperatures for every record low. In the 1990s, the ratio of record-highs to lows was 1.4. And in the 2010s, through Sept. 6, there were 1.7 record highs for every record low.

This ratio is even higher in certain regions. In the Northeast, which stretches from Maryland to Maine, there have been 2.2 record-high night temperatures set for every record low since 2010. In Utah, Colorado, Arizona and New Mexico, the ratio is 3.4. And in California and Nevada, the ratio is 3.6.