Upvote:3
Your 90 days period begins as you enter the country. Note that the immigration officer has the possibility to grant you less than 90 days if she/he feels that this is appropriate. So make sure that you mention during your interview that you need the full 90 days, and be prepared to show proof that you have the financial means to support you during your stay. They are more likely to ask for that when it come to longer stays.
The VWP ESTA is valid for two years and it only needs to be valid for entering the country, not for the complete duration of your stay.