The best time to visit is in the morning (get there before opening), ride as many rides as you can and get fastpasses for as many rides as you can (you can use them anytime after the return window opens, even up until the park closes). The afternoons get very crowded, so you can use some of your fastpasses or watch the parade. Take a break and then come back for evening activities, but keep in mind that most of the evening will be taken up waiting for the fireworks or Fantasmic, unless you decide to skip these to do more rides (recommend seeing them both, but not on the same night). It is almost impossible to move around the park once the fireworks start, so get where you want to be and plan to spend the rest of the night there. I recommend at least 2 days for Disneyland, preferably 3, plus one day for California Adventure. Again, you can get more rides done between opening and 11am than you can the entire rest of the day, so get there early!
If you can afford it, it is really nice to stay onsite, but there are many motels just across the street that are decent (think 2-3 stars). The best choices seem to be Candy Cane Inn (you have to contact them directly or visit their website to make reservations, you will not find them on Expedia etc.), Hojo, Carousel Inn, and BW Park Place Inn. I personally don't think Knott's Berry Farm is worth it, but Universal Studios is fun if you have a car and an extra day.