A woman who had been a Nidda must count seven "clean days" and then immerse after dark at the end of the seventh day. The immersion should not be done before dark; she must wait until after nightfall at the end of the seventh day before immersing in the Mikveh. Nevertheless, the Shulhan Aruch rules that if, for whatever reason, the woman immersed before sundown on the seventh day, the immersion is valid and she does not have to immerse again after dark.
Furthermore, there are certain extenuating circumstances in which Halacha permits a woman to immerse before sundown. One example is when the immersion is scheduled to take place on Friday night, and the nearest Mikveh is far from one’s home. In this case, if the woman immerses after dark, she would be unable to return home on Shabbat. Under such circumstances, Halacha permits the woman to immerse before Shabbat and then return home. However, since she does not become permissible to her husband until after nightfall, it is forbidden for her to be together with her husband in the interim. Therefore, in such a case, the husband and wife must arrange for the husband to be somewhere else when the wife returns home from the Mikveh before Shabbat. These Halachot are codified by Hacham Ovadia Yosef in his Taharat Ha’bayit (p. 492; listen to audio recording for precise citation).
It must be emphasized that this dispensation is given only in cases that clearly qualify as "Sha’at Ha’dahak" – extenuating circumstances. One must ensure not to abuse this Halacha by allowing a woman to immerse before sundown purely for the sake of convenience. For example, if a couple is going on vacation together and their flight leaves in the early evening, this does not qualify as a "Sha’at Ha’dahak" to allow the woman to immerse before sundown. (In any event, in this case she would be forbidden to be together with her husband on the plane before dark.) Another situation in which this Halacha could be misapplied is when a couple is invited to friends for Friday night dinner, and the wife wants to be able to put on makeup before dinner. This concern is not regarded as "extenuating circumstances" that allow for immersing before sundown. It is imperative to consult with a Rabbi for guidance to determine if a certain problem allows a wife to rely on this special dispensation and immerse before sundown. Certainly, it would be wrong to establish as a matter of policy that a woman may immerse before sundown whenever it would be difficult to immerse after dark.
Summary: A woman’s immersion after the seven "clean days" must take place after dark. When extenuating circumstances arise, one must consult with a Rabbi for guidance, as in certain situations it may be permissible to immerse already before sundown on the seventh day. As a rule, however, this is forbidden.