By what time does the Afikoman have to be eaten by?
One must beware to eat the Afikoman prior to midnight. [The Chabad custom is to be particular in this matter only on the first night of Seder, while on the second night one can delay its eating until later. On the first night, if one is before in in middle of Shulchan Oreich and sees he will not be able to eat the Afikoman before Chatzos then he can perform the following Tnaiy/stipulation to fulfill his obligation according to all: As midnight approaches he is to eat a Kezayis of Matzah while leaning with intent to fulfill his obligation of Afikoman only if the ruling follows the opinion of Rebbe Elazar Ben Ezaria, but not if the ruling follows the opinion of Rebbe Akiva. He is then not to eat or drink until midnight. After midnight, he is to continue his meal, and Seder as usual. Upon reaching the official Afikoman he is to repeat the eating of Afikoman according to all its laws, fulfilling his obligation if the ruling follows the opinion of Rebbe Akiva. By making the above stipulation he adheres to the warning to eat the Afikoman before midnight, and at the same time does not transgress the prohibition of eating after his initial Afikoman.]
 Admur 477/6; Siddur Admur; Sefer Haminhagim [English] p. 75; Michaber 477/1; This follows the opinion of Rebbe Elazar Ben Azaria in Pesachim 120b; Zevachim 57b; Tosafus Zevachim ibid; Megillah 21a; Piskeiy Tosafus Pesachim 334; Zevachim 33; Rosh 10/38 in name of Rabbeinu Tam; Rabbeinu Chananel in Arvei Pesachim; Semag in name of Riy; Mordechai end of Pesachim; Rabbeinu Yerucham 5/4; Conclusion of Or Zarua; Hapardes 9/16-26 “It is forbidden to eat Matzah after midnight”; See Biur Halacha 477/1 “Viyihei Zahir”
Other opinions: Some Poskim rule the Pesach may be eaten until Alos Hashachar, and accordingly, one fulfills his obligation of Matzah until Alos. [Rebbe Akiva in Pesachim and Zevachim ibid; Rambam Karban Pesach 8/15; Chametz Umatzah 6; Rif [brought in Mishkanos Yaakov 139] Rav Hamaggid; Baal Haitur; Or Zarua in name of Rav Yaakov of Krubil; Kol Bo 90; See Biur Halacha 477/1 “Viyihei Zahir”] Accordingly, there are those who are even initially lenient to eat the Afikoman after midnight even on the first night. [Minhagei Chasam Sofer; Netziv; Darkei Chaim Veshalom 605; Minchas Yitzchak 9/48; See Piskeiy Teshuvos 477/3]
The Rebbe’s custom: Rabbi Shmutkin of Chabad Michigan told over that he participated in many Sedarim at the Rebbe’s household. He was appointed in charge of letting the Rebbe know the time in order to keep track of Chatzos. The Rebbe would ask him the time at various segments of the Hagada. Hence, we see the Rebbe was very particular to eat the Afikoman prior to Chatzos, unlike those who are lenient in this matter.
 The reason: Just as the Karban Pesach was only eaten until midnight [so too the Matzah]. [Admur ibid] As the verse states Al Matzos Umerorim Yochluhu, thus teaching us that the eating of Matzah is connected, and follows similar laws, to the Pesach regarding its conclusion of eating. [Admur 458/2]
 Sefer Haminhagim ibid
 Avnei Nezer 381; See Piskeiy Teshuvos 477 footnote 5; See previous footnotes and opinions mentioned there for the full understanding of this stipulation.
 The reason: As according to Reb Elazar Ben Ezaria, the prohibition of eating after the Afikoam only applies so long as the Mitzvahg is stioll applicable, which in his opinion is only until midnight. Thus, when one intends to eat the Afikoman before midnight only according to his opinion, then the prohibition of eating afterwards only applies until midnight. After midnight he may resume eating according top all, as if we rule like Rebbe Akiva, then he did not yet fulfil the Mitzvah of Afikoman, per his stipulation, and if we rule like Reb Elazar Ben Azaria, the obligation was already fulfilled and expired.