It is narrated from Sayyiduna Anas (may Allah be pleased with him) that when the Prophet (peace and blessings be upon him) was resident, he would observe i'tikaf in the last ten days of Ramadan, and when he travelled, he would observe i'tikaf for twenty days the following year.
Abu Abd al-Rahman Abdullah bin Ahmad (may Allah have mercy on him) said that his father, Imam Ahmad bin Hanbal (may Allah have mercy on him), said: "I heard this hadith only from Ibn Abi Adi (may Allah have mercy on him), from Humayd (may Allah have mercy on him), from Sayyiduna Anas (may Allah be pleased with him)."
Imam al-Daraqutni (may Allah have mercy on him) said: "Ibn Abi Adi (may Allah have mercy on him) is alone in narrating it, whereas Hammad bin Salamah (may Allah have mercy on him) narrated it from Humayd (may Allah have mercy on him), from Abu Nadrah (may Allah have mercy on him), from Sayyiduna Abu Sa'id (may Allah be pleased with him)."
Imam al-Tirmidhi (may Allah have mercy on him) narrated it from Bundar (may Allah have mercy on him), from Ibn Abi Adi (may Allah have mercy on him), from Humayd (may Allah have mercy on him), from Sayyiduna Anas (may Allah be pleased with him), and said: "This hadith is hasan sahih gharib as a narration of Sayyiduna Anas (may Allah be pleased with him)."
Imam Abu Hatim Ibn Hibban (may Allah have mercy on him) also narrated it through Muhammad bin Abd al-Rahman al-Sami (may Allah have mercy on him) from Imam Ahmad bin Hanbal (may Allah have mercy on him).
Related hadith on this topic