The Prophet ﷺ used to observe seclusion during the last ten days of Ramadan. One year he was traveling, so the following year he observed seclusion for twenty days.
حدثنا محمد بن يحيى حدثنا عبد الرحمن بن مهدي عن حماد بن سلمة عن ثابت عن أبي رافع
أن النبي ﷺ كان يعتكف العشر الأواخر من رمضان فسافر عاما فلما كان من العام المقبل اعتكف عشرين يوما
Its isnad is sahih. Abu Dawud narrated it in the Book of Fasting, chapter on itikaf, hadith no. 2463, from the hadith of Hammad, with this wording. Ibn Khuzayma, Ibn Hibban, Hakim, and Dhahabi graded it sahih.