I started driving again at 4-5 weeks. Some people start sooner, some later.
Of course, you need to be able to get into and out of the car and adjust the driver's seat.
You do need to be off the heavy-duty narcotics - don't want to be driving "under the influence".
You need to be sure that you can think clearly, that the post-op, sedated brain fog has lifted.
You need to be 120% certain that you can do an emergency stop.
Some insurance companies require that you get a clearance to drive from your surgeon. It's worth asking if your company is one of those.
If you drive an automatic, you can possibly start driving a little earlier if it's your left knee that is replaced. The right knee would take a little longer.
Before I started driving, I would sit in the car with the engine turned off and practice moving my feet from pedal to pedal. I'd practice doing emergency stops.
I drive a manual car (stick shift), so I had three pedals to negotiate and needed to use both my feet - I could probably have started a week or so earlier, if I had an automatic.
When I was sure I could work the pedals OK, I practiced driving slowly on our driveway first, and then on a quiet road.
Only take short trips at first - you'll find that you tire easily and your knee won't like being kept in one position for very long.