Gov. Gavin Newsom on Sunday signed first-of-its-kind legislation to mandate later start times at California middle and high schools.

Under SB 328 school days will begin no earlier than 8 a.m. at public middle schools and 8:30 a.m. at public high schools, excluding some rural schools and a “zero period” offered before the start of the regular school day.

The law is set to go into effect July 1, 2022.

Teachers and school districts opposed the law, arguing the decision on when to start school should be left to local officials.

Concerns were also raised about how the later start times might affect working parents who need to drop their children off at school.

“We should not set the bell schedule from Sacramento,” said Assemblyman Patrick O’Donnell, D-Long Beach, chairman of the Assembly Education Committee. “Sacramento does not know best.”

But the bill’s author, state Sen. Anthony Portantino, said Newsom’s signature “put our children’s health and welfare ahead of institutional bureaucracy resistant to change.”

“Shifting to a later start time will improve academic performance and save lives because it helps our children be healthier,” Portantino said.

The California State PTA co-sponsored the bill. Speaking on the group’s behalf, Carol Kocivar said, “When teens get enough sleep, they are safer, healthier and do better in school. The California State PTA is proud to co-sponsor this bill and looks forward to helping implement this historic initiative across our state.”

Last year, a similar Portantino bill was sent to then-Gov. Jerry Brown, who vetoed it.

The Associated Press contributed to this report.