There is no real rule when it comes to meditation and to how long you should meditate for, it's really up to you.
As a general guideline, though, it's strongly recommended to start out small.
Start with short periods of time, such as 5-minute sessions once or twice a day, and build it up slowly.
It may seem like too little, but even 5 minutes a day of being mindful and meditating can have a huge impact on the rest of your day or night, depending on when you decide to do it.
The reason this is strongly advised is because sitting in meditation can be very difficult, much more difficult than many people actually think.
To sit down for a lengthy time period doing nothing but following your breath or listening to a sound can be a very strange sensation, and one that is simply difficult to do.
Starting out with long sessions is a very risky way to start this practice since you can risk losing motivation for the practice once you see that sitting for 30 minutes or longer is difficult.
Start out with short, 5-minute sessions once a day, then add another session when ever you can. Once that gets easy, you will see that you can naturally progress and add more time to each session. Eventually, you will make your way to those 20-30 minute sessions.
Progressing slowly helps ensure that you do not lose motivation for the practice, and that you don't stress yourself out about not being able to meditate for long periods of time.