Whenever the Messenger of Allah ﷺ intended to observe itikaf, he would pray the Fajr prayer and then enter his place of seclusion.
كان رسول الله ﷺ إذا أراد أن يعتكف، صلى الفجر، ثم دخل معتكفه.
Bukhari narrated it in the Book of Itikaf (2041), and Muslim in the Book of Itikaf (6:1172), through Yahya bin Saeed (that is, Ansari), who said, Amra bint Abdul-Rahman narrated to me, from Ayesha, who said (and then she mentioned it), and the wording given is Muslim's.Tirmidhi said, following his citation of this hadith, "The practice among some scholars is that when a man wants to observe itikaf, he prays Fajr, then enters his place of itikaf. This is the view of Ahmad and Ishaq bin Ibrahim. Others said, when he wants to observe itikaf, the sun should set on the night before the day on which he intends to begin, and he should already be seated in his place of itikaf. This is the view of Sufyan Thawri and Malik bin Anas." End of quote.Her statement, "when he had prayed Fajr," refers to the Fajr of the twentieth day, because daytime is the time for fasting, so his itikaf during the last ten days began in the daytime while he was fasting. As for those who said "after sunset," they mean the night of the twentieth, because that night falls within the last ten days. This is why they interpreted Ayesha's hadith to mean that he entered at the very beginning of the night, but in fact he only withdrew by himself into the place he had prepared for itikaf after the dawn prayer.See Nayl Awtar (3/251).