Just to add to what JK said, California law is kind of quirky about how one must give notice.
To end a periodic rental agreement (for example, a month-to-month agreement), you must give your landlord proper written notice before you move.
You must give the landlord the same amount of notice as there are days between rent payments. This means that if you pay rent monthly, you must give the landlord written notice at least 30 days before you move. If your rental agreement specifies a different amount of notice (for example 10 days), you must give the landlord written notice as required by the agreement. At the time you give notice, the rent shall be due and payable up to and including the date of termination and must accompany your written notice.
To avoid later disagreements, date the notice, state the date that you intend to move, and make a copy of the notice for yourself. It's best to deliver the notice to the landlord or property manager in person, or mail it by certified mail with return receipt requested.
You can give the landlord notice any time during the rental period, but you must pay full rent during the period covered by the notice. For example, say you have a month-to-month rental agreement, and pay rent on the first day of each month. You could give notice any time during the month (for example, on the tenth). Then, you could leave 30 days later (on the tenth of the following month, or earlier if you chose to). But you would have to pay rent for the first 10 days of the next month whether you stay for those 10 days or move earlier. (Exception: You would not have to pay rent for the entire 10 days if you left earlier, and the landlord rented the unit to another tenant during the 10 days, and the new tenant paid rent for all or part of the 10 days.)

