I am trying to figure out, during Apollo missions, exactly when the lunar-module extended the landing gear. Was it closer to the time the CM and LM connected in the space rendezvous or did they extend the landing gear closer to arriving to the Moon?
It was done on "PDI Day" (Powered Descent Initate), the day of landing.
The Apollo Flight Journal is a fantastic resource for answering these sorts of questions. For every mission, it has a complete transcript of everything said, both over the radio and within the spacecrafts. Every significant event is narrated there, with mission timestamps as Hours:Minutes:Seconds since liftoff.
098:14:07 Armstrong (onboard): Okay, we're going to put our gear down. 098:14:29 Aldrin (onboard): [Garble] Master Arm... 098:14:34 Armstrong (onboard): Okay. 098:14:35 Aldrin (onboard): Landing Gear Deploy, Fire. 098:14:37 Armstrong (onboard): Here we go, Mike. 098:14:46 Aldrin (onboard): Bam, it's out. Ain't no doubt about that. 098:14:50 Armstrong (onboard): And it's gray.
The Lunar Module's four landing legs have deployed to the open position with a bang, and the talkback indicator on the instrument panel has turned grey, as confirmation.
The above exchange took place while the Command Module and Lunar Module were still docked together in lunar orbit, prior to separation and the LM's descent.
Approximately two hours later, as part of Day 5, part 2: Undocking and the Descent Orbit, the LM undocked, and as it moved away, spun so Collins could visually check that the legs were deployed properly:
As the LM moves away, Neil rotates the lander to allow Mike to inspect its exterior and in particular, to ensure that the four landing gear are properly deployed.
Photograph AS11-44-6574 (among others) captures this moment:
So, to summarize, they were deployed while docked in lunar orbit, and successful deployment was visually confirmed right after separation.