Depends. Bladder function after surgery can depend on many things. Longer anesthesia, longer surgery, complicated pelvic surgery may have a few days before bladder function returns. If it is a shorter surgery or less complicated surgery, the bladder function may be normal immediately after surgery.
Within a day. As men grow older they are more likely to develop benign prostatic hypertrophy. This is not usually a problem, but under anesthesia can cause urinary retention. This is usually very short lasting and is easily treated. Most post operative care locations will make sure you urinate before you leave. The symptoms have shown up later. You will be counseled on this before discharge.
Not long. Usually only an hour or two, although it may take longer for some individuals.