If you really have to pee you can usually hold your pee in for around 30 minutes to an hour before you lose bladder control and the pee comes out on it's own.
I was once on a road trip and had been holding my pee for 20 minutes already while on the road trip and when I finally stopped at a gas station and went into the gas station to go to the restroom someone was already in the restroom for 15 minutes before I got into the restroom.
After 30 minutes of holding the pee in I had lost bladder control because I could no longer hold in the pee any longer and I wet my pants and had to clean up and then get a new pair of pants and underwear to change into.
Now if I have to pee and there's no restroom nearby I'll pull over if possible and pee on the side of the road to prevent wetting my pants again.