Sahih al-Bukhari, Book 33, Hadith 19 (Bukhari 1970)

Narrated Abu Huraira:

The Prophet (ﷺ) used to perform I`tikaf every year in the month of Ramadan for ten days, and when it was the year of his death, he stayed in I`tikaf for twenty days.