Hi, I know I apply online for a visa to Sri Lanka but how early should I apply? Is it valid from the date of issue or can it be post-dated to the date of arrival?

I think they say how long before you need to use it on the SL Immigration Office website. A few months I think.
Nonetheless it only takes a day or two to be processed, so get it a couple of weeks before you leave.
Your 30 days start when you enter the country.
Enjoy.

I agree that the processing is normally very quick, but occasionally it can take a bit longer. I don't know if it is a technical thing, eg computer down, or that some visas are referred for a manual check.
I've had 3 visas in last 2 years.
If you have time it's always best to do it at least a week in advance just in case. You can also get one at the airport for a few dollars more.

Amazing - applied this afternoon and got automated acknowledgement followed by approval 2 minutes apart! I guess I should print the approval e-mail off??

They do recommend you print it off, not really necessary as they don't look at it as it is all online their end. Of course, you may be asked to show at at airport check in.
It's not surprising it's quick, it's a pure tourist tax. Who would turn down $30 by the tens of thousands. A few years ago as a Brit, you got a month free.
Enjoy your trip.