I've not heard people talk about two oscillators at different frequencies being "in phase." Instead, I will present a solution for time instants when the two oscillators will be at the same angular displacement:phase in their oscillation.
WLOG, let $\theta_1(0)=0$ (no phase shift), and let $\phi$ represent the phase shift of the second oscillator$\theta_1(0)=\theta_2(0)=0$. Define $\omega_i\equiv\sqrt{\frac{g_i}{l}}$ for $i\in\{1,2\}$; i.e. the angular frequency of the two oscillators.
Then, we have $\theta_1(t)=A_1\sin(\omega_1t)$ and $\theta_2(t)=A_2\sin(\omega_2t+\phi)$$\theta_2(t)=A_2\sin(\omega_2t)$. To find when the two oscillators coincide in phase, we find solutions of $t$ to the following equation:
$$A_1\sin(\omega_1t)=A_2\sin(\omega_2t+\phi)$$$$\sin(\omega_1t)=\sin(\omega_2t)$$
I believeIt's easiest to visualize solutions for this is best done numericallyequation by graphing $\sin(x)=\sin(y)$. Solutions to this happen when $(\omega_1-\omega_2)t=2\pi i$ or graphically$(\omega_1+\omega_2)t=\pi+2\pi i$, for $i\in\mathbb{Z}$.
Rearranged for $t$, we have $t=\frac{2\pi i}{\omega_1-\omega_2}$ and $t=\frac{\pi+2\pi i}{\omega_1+\omega_2}$.