(CNN) Students in California, rejoice. You'll soon be able to sleep in a little more.

Gov. Gavin Newsom signed legislation on Sunday that pushes school start times later. Under the new law, middle schools will start classes at 8 a.m. or after, while high schools will start classes at 8:30 a.m. or after. Optional early classes will still be allowed.

The law applies to public and charter schools, though rural school districts are exempt. The new start times go into effect by July 1, 2022, or when a school's collective bargaining agreement with its employees expires, whichever is later.

State Sen. Anthony Portantino, who authored the bill, cheered the news in a Facebook post on Sunday.

"Our children's health and welfare win!!! Thank you Governor Newsom for signing SB 328 to push high school and middle school start time later in the morning. This will have a tremendous benefit to student health and academic performance."

Read More