An electro-optical time gating technique, which is based on an electrical return-to-zero (RZ) pulse driven Mach-Zehnder modulator (MZM) for eliminating multiple access interference (MAI) in optical code-division multiple access (OCDMA) networks is proposed. This technique is successfully simulated in an eight-user two-dimensional wavelength-hopping time-spreading system, as well as in a three-user temporal phase encoding system. Results show that in both systems the MAI noise is efficiently removed and the average received power penalty improved. Both achieve error-free transmissions at a bit rate of 2.5 Gb/s . In addition, we also individually discuss effects of parameters in two systems, such as the extinction ratio of the MZM, the duty cycle of the driven RZ pulse, and the time misalignment between the driven pulse and the decoded autocorrelation peak, on the output bit error rate performance. Our work shows that employing a common MZM as a thresholder provides another probability and an interesting cost-effective choice for a smart size, low energy, and less complex thresholding technique for integrated detection in OCDMA networks.