When to buy a crib?

Sam
Hey ladies,
When is the best time to buy a crib for the baby? Do I need to have it before the baby is here or can we wait till after the birth to make the purchase? I have heard that there might be a law surrounding when by we should have the crib, so wanted to check.
Thoughts?
Thanks
Sam