You must present a clear danger to (a) yourself or (b) others. You can have someone call an ambulance for you or you can go to the ER and tell them you think you are a danger to yourself and they will take you to a place for admission. I think if it's voluntary it might be a 5152, I can't remember. That gets you a minimum 72 hour hold.
Anyway, the problem I found from being thrown in a mental hospital is that they are not really intersted in helping you, except with medication. So I found it incredibly frustrating. You have group therapy usually with just an orderly and not even a real counselor, and then you see a pshychiatrist for approximately 2 minutes each day and they throw all these meds at you.
On the other hand, it is a place to go when you feekl you just can't cope with everything else and it can give soem good thinking time. just beware of them screwing with a bunch of meds.