The Best Time to Go: As soon as the seatbelt sign is off, before drink service begins.
Timing is everything, says Roth. As soon as the seat belt sign goes off, make a break for the lavatory. If that’s not an option, the next best time is right before drink service begins. People see the carts coming down the aisle and don’t want to miss their opportunity to snag a free Fresca and some peanuts, so they stay in their seats. This gives you a small window of privacy if you think fast.
Time Limit: Five minutes, 10 max. Twenty minutes will get you a knock on the door
If you’re worried about the smell, Roth suggests you ask for some coffee ground packets and hang them up in the lavatory before you do your business. The flight attendants will know what’s going on, but at least you won’t stink up the cabin for everybody else. A small bottle of air freshener spray might be good to pack too. Just don’t try to cover up the smell with cologne or perfume as that will only make things worse.
Source: lifehacker.com and melmagazine.com